Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a single form interface for a company that sells popcorn tins. Your job i

ID: 3788429 • Letter: D

Question

Design a single form interface for a company that sells popcorn tins. Your job is to create a popcorn order based on user input, so you will need a supporting class to create the popcorn object. Your form should not handle any other information about the order (customer, total order, other food items, etc.). Following are the attributes of the tins that the company sells. Your supporting class should reflect these in the class fields. You may use enumerated types if you are familiar with them, but it is not required. Feel free to constrain user input with combo boxes. size: 1, 2, and 3 gallon sizes color: red, green, or blue flavor: plain, cheese, caramel mixed: two flavors can be mixed, if desired price: the price of the item gift: whether or not the tin is a gift giftMessage: message to paint on the tin You do not need to include any images in your form, unless you want to. Feel free to get creative with your form, as long as the following elements are included to create the popcorn tin object. NOTE: your form needs to create only one object. comboBox – for size,color, and flavor radioButton – for mixed and gift options labels – to identify all controls textField – to enter gift message, if needed button – one to create popcornTin object, one to clear the form return focus to first component textArea – to display the object as created with user choices Your form should follow rules of good design, including but not limited to, form layout, choice of colors and fonts, tab order, and enabling of elements as appropriate. A project earning a 100 will successfully run, and create and display the popcorn object in the text Area.This is my code so far I need to be able to clear the order that the user submits.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class PopcornTin extends JFrame{

   /**
   *
   */
   private static final long serialVersionUID = 1L;
   public PopcornTin(){
       super ("PopcornTin");
       getContentPane().setLayout(new FlowLayout());
       String[] colortext = new String[] { "Red"," Green","Blue"};
       String[] sizetext = new String[] {"1 Gallon"," 2 Gallons","3 Gallons"};
       String[] flavortext = new String[] { "Plain"," Cheese","Caramel"};
       JLabel size = new JLabel("Size");
       JLabel color = new JLabel("Color");
       JLabel flavor = new JLabel("Flavor");
       JLabel mixed = new JLabel("Mixed");
       JLabel price = new JLabel("Price");
       JLabel gift = new JLabel("Gift");
       JLabel msg = new JLabel("Gift Message");
       JComboBox CSize = new JComboBox<>(sizetext);
       JComboBox CColor = new JComboBox<>(colortext);
       JComboBox CFlavor = new JComboBox<>(flavortext);
       JTextField textField1 = new JTextField("", 5);
       JTextField textField2 = new JTextField("", 15);
       JRadioButton but1 = new JRadioButton("Yes");
       JRadioButton but2 = new JRadioButton("No");
       JRadioButton but3 = new JRadioButton("Yes");
       JRadioButton but4 = new JRadioButton("No");
       JButton create = new JButton("Create");
       JButton clear = new JButton("Clear");
       ButtonGroup group1 = new ButtonGroup();
       group1.add(but1);
       group1.add(but2);
       ButtonGroup group2 = new ButtonGroup();
       group2.add(but3);
       group2.add(but4);
       getContentPane().add(BorderLayout.SOUTH, size);
       getContentPane().add(CSize);
       getContentPane().add(CColor);
       getContentPane().add(color);
       getContentPane().add(CColor);
       getContentPane().add(flavor);
       getContentPane().add(CFlavor);
       getContentPane().add(mixed);
       getContentPane().add(but1);
       getContentPane().add(but2);
       getContentPane().add(price);
       getContentPane().add(textField1);
       getContentPane().add(gift);
       getContentPane().add(but3);
       getContentPane().add(but4);
       getContentPane().add(msg);
       getContentPane().add(textField2);      
       getContentPane().add(create);
       getContentPane().add(clear);
       create.addActionListener(new ActionListener(){
      
       public void actionPerformed(ActionEvent evt) {
           String str = evt.getActionCommand();
           if(str.equalsIgnoreCase("create"))
           {
           String s="Size:"+(String)CSize.getSelectedItem();
           String c="Color:"+(String)CColor.getSelectedItem();
           String f="Falvor:"+(String)CFlavor.getSelectedItem();
           String m="Mixed:",g="Gift:",gmes="";
           if(but1.isSelected() == true)
           m=m+"Yes";
           else if(but2.isSelected() == true)
           m=m+"No";
           String price="Price:"+textField1.getText();
           if(but3.isSelected() == true)
           g=g+"Yes";
           else if(but4.isSelected() == true)
           g=g+"No";
           gmes="Gift Message:"+textField2.getText();
           String totalmessage=s+" "+c+" "+f+" "+m+" "+price+" "+g+" "+gmes;
           TextArea obj = new TextArea("Object has been created "+totalmessage,10,30);
           obj.setBounds(50,400,300,100);
           getContentPane().add(obj);
           validate();
           }
           else if(str.equalsIgnoreCase("clear"))
           {
             
           String str1 = textField1.getText();
           String str2 =textField2.getText();

           textField1.setText("");
           textField2.setText("");

           }
               }
              
              
          
          
       });
       setSize(300,500);
       setVisible(true);
              
   }
   /**
   * @param args
   */
   public static void main(String[] args) {
       new PopcornTin();
   }

}

Explanation / Answer

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class PopcornTin extends JFrame{

   /**
   *
   */
   private static final long serialVersionUID = 1L;
   public PopcornTin(){
       super ("PopcornTin");
       getContentPane().setLayout(new FlowLayout());
       String[] colortext = new String[] { "Red"," Green","Blue"};
       String[] sizetext = new String[] {"1 Gallon"," 2 Gallons","3 Gallons"};
       String[] flavortext = new String[] { "Customer"," total order" "other food items"};
       JLabel size = new JLabel("Size");
       JLabel color = new JLabel("Color");
       JLabel flavor = new JLabel("Flavor");
       JLabel mixed = new JLabel("Mixed");
       JLabel price = new JLabel("Price");
       JLabel gift = new JLabel("Gift");
       JLabel msg = new JLabel("Gift Message");
       JComboBox CSize = new JComboBox<>(sizetext);
       JComboBox CColor = new JComboBox<>(colortext);
       JComboBox CFlavor = new JComboBox<>(flavortext);
       JTextField textField1 = new JTextField("", 5);
       JTextField textField2 = new JTextField("", 15);
       JRadioButton but1 = new JRadioButton("Yes");
       JRadioButton but2 = new JRadioButton("No");
       JRadioButton but3 = new JRadioButton("Yes");
       JRadioButton but4 = new JRadioButton("No");
       JButton create = new JButton("Create");
       JButton clear = new JButton("Clear");
       ButtonGroup group1 = new ButtonGroup();
       group1.add(but1);
       group1.add(but2);
       ButtonGroup group2 = new ButtonGroup();
       group2.add(but3);
       group2.add(but4);
       getContentPane().add(BorderLayout.SOUTH, size);
       getContentPane().add(CSize);
       getContentPane().add(CColor);
       getContentPane().add(color);
       getContentPane().add(CColor);
       getContentPane().add(flavor);
       getContentPane().add(CFlavor);
       getContentPane().add(mixed);
       getContentPane().add(but1);
       getContentPane().add(but2);
       getContentPane().add(price);
       getContentPane().add(textField1);
       getContentPane().add(gift);
       getContentPane().add(but3);
       getContentPane().add(but4);
       getContentPane().add(msg);
       getContentPane().add(textField2);      
       getContentPane().add(create);
       getContentPane().add(clear);
       create.addActionListener(new ActionListener(){
      
       public void actionPerformed(ActionEvent evt) {
           String str = evt.getActionCommand();
           if(str.equalsIgnoreCase("create"))
           {
           String s="Size:"+(String)CSize.getSelectedItem();
           String c="Color:"+(String)CColor.getSelectedItem();
           String f="Falvor:"+(String)CFlavor.getSelectedItem();
           String m="Mixed:",g="Gift:",gmes="";
           if(but1.isSelected() == true)
           m=m+"Yes";
           else if(but2.isSelected() == true)
           m=m+"No";
           String price="Price:"+textField1.getText();
           if(but3.isSelected() == true)
           g=g+"Yes";
           else if(but4.isSelected() == true)
           g=g+"No";
           gmes="Gift Message:"+textField2.getText();
           String totalmessage=s+" "+c+" "+f+" "+m+" "+price+" "+g+" "+gmes;
           TextArea obj = new TextArea("Object has been created "+totalmessage,10,30);
           obj.setBounds(50,400,300,100);
           getContentPane().add(obj);
           validate();
           }
           else if(str.equalsIgnoreCase("clear"))
           {
             
           String str1 = textField1.getText();
           String str2 =textField2.getText();

           textField1.setText("");
           textField2.setText("");

           }
}
          
       });
       setSize(300,500);
       setVisible(true);
              
   }
   /**

   public static void main(String[] args) {
       new PopcornTin();
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote