combo boxes

combo boxes

how do you store numbers in the choices. ex. soda is $.75 and tax is $.07 then it equals a new total. I've been trying to use the Itemlistener but i can't figure out how to store the numbers

import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.ButtonGroup; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JRadioButton; import javax.swing.JTextField;

import javax.swing.WindowConstants; import javax.swing.SwingUtilities;

public class BurgeMenu extends javax.swing.JFrame implements ItemListener
{ private JLabel jLabel1; private JLabel jLabel2; private JLabel jLabel3; private JLabel jLabel4; private JLabel jLabel5; private JRadioButton jRadioButton5; private JRadioButton jRadioButton4; private JRadioButton jRadioButton3; private JRadioButton jRadioButton2; private JRadioButton jRadioButton1; private ButtonGroup buttonGroup1; private JTextField totalbox; private JTextField taxbox; private JTextField subtbox; private JButton jButton1; private JButton jButton2; private JLabel jLabel8; private JLabel jLabel7; private JLabel jLabel6; private JComboBox jComboBox2; private JComboBox jComboBox1; private JTextField sprqst; double Cheeseburger = 2.49; double DoubleCheeseburger = 3.89; double TripleCheeseburger = 4.99; double Medium = .75; double Large = 1.25; double tax = .07; double subtotal; double total;

/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            BurgeMenu inst = new BurgeMenu();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
        }
    });
}

public BurgeMenu() {
    super();
    initGUI();
}

private void initGUI() {
    try {
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("McDowell's");
            jLabel1.setBounds(204, 0, 125, 30);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("ComboMeal");
            jLabel2.setBounds(24, 43, 90, 16);
        }
        {
            jLabel3 = new JLabel();
            getContentPane().add(jLabel3);
            jLabel3.setText("SpecialRequest:");
            jLabel3.setBounds(24, 76, 129, 16);
        }
        {
            jLabel4 = new JLabel();
            getContentPane().add(jLabel4);
            jLabel4.setText("Drinks:");
            jLabel4.setBounds(24, 110, 72, 16);
        }
        {
            sprqst = new JTextField();
            getContentPane().add(sprqst);
            sprqst.setBounds(171, 73, 158, 22);
        }
        {
            ComboBoxModel jComboBox1Model = 
                new DefaultComboBoxModel(
                        new String[] { "1.Cheeseburger", "2.Double Cheeseburger","3.Triple Cheeseburger" });
            jComboBox1 = new JComboBox();
            getContentPane().add(jComboBox1);
            jComboBox1.setModel(jComboBox1Model);
            jComboBox1.setBounds(171, 36, 166, 22);
            jComboBox1.addItemListener(this);
        }
        {
            jLabel5 = new JLabel();
            getContentPane().add(jLabel5);
            jLabel5.setText("Size:");
            jLabel5.setBounds(24, 163, 56, 16);
        }
        {
            ComboBoxModel jComboBox2Model = 
                new DefaultComboBoxModel(
                        new String[] { "Small", "Medium","Large" }); 

            jComboBox2 = new JComboBox();       
            getContentPane().add(jComboBox2);
            jComboBox2.setModel(jComboBox2Model);
            jComboBox2.setBounds(171, 160, 132, 22);
            jComboBox2.addItemListener(this);
        }
        {
            jLabel6 = new JLabel();
            getContentPane().add(jLabel6);
            jLabel6.setText("Subtotal:");
            jLabel6.setBounds(24, 205, 72, 16);
        }
        {
            jLabel7 = new JLabel();
            getContentPane().add(jLabel7);
            jLabel7.setText("Tax:");
            jLabel7.setBounds(24, 245, 56, 16);
        }
        {
            jLabel8 = new JLabel();
            getContentPane().add(jLabel8);
            jLabel8.setText("Total:");
            jLabel8.setBounds(24, 288, 56, 16);
        }
        {
            jButton1 = new JButton();
            getContentPane().add(jButton1);
            jButton1.setText("Submit Order");
            jButton1.setBounds(171, 324, 117, 22);
        }
        {
            jButton2 = new JButton();
            getContentPane().add(jButton2);
            jButton2.setText("Clear");
            jButton2.setBounds(316, 324, 71, 22);
        }
        {
            subtbox = new JTextField();
            getContentPane().add(subtbox);
            subtbox.setBounds(171, 202, 68, 22);
        }
        {
            taxbox = new JTextField();
            getContentPane().add(taxbox);
            taxbox.setBounds(171, 242, 68, 22);
        }
        {
            totalbox = new JTextField();
            getContentPane().add(totalbox);
            totalbox.setBounds(171, 285, 68, 22);
        }
        {
            jRadioButton1 = new JRadioButton();
            getContentPane().add(jRadioButton1);
            jRadioButton1.setText("Coke");
            jRadioButton1.setBounds(171, 108, 60, 20);
            getButtonGroup1().add(jRadioButton1);
        }
        {
            jRadioButton2 = new JRadioButton();
            getContentPane().add(jRadioButton2);
            jRadioButton2.setText("Sprite");
            jRadioButton2.setBounds(171, 131, 64, 20);
            getButtonGroup1().add(jRadioButton2);
        }
        {
            jRadioButton3 = new JRadioButton();
            getContentPane().add(jRadioButton3);
            jRadioButton3.setText("Diet Coke");
            jRadioButton3.setBounds(236, 108, 85, 20);
            getButtonGroup1().add(jRadioButton3);
        }
        {
            jRadioButton4 = new JRadioButton();
            getContentPane().add(jRadioButton4);
            jRadioButton4.setText("Root Beer");
            jRadioButton4.setBounds(235, 131, 82, 20);
            getButtonGroup1().add(jRadioButton4);
        }
        {
            jRadioButton5 = new JRadioButton();
            getContentPane().add(jRadioButton5);
            jRadioButton5.setText("Orange");
            jRadioButton5.setBounds(321, 108, 68, 20);
            getButtonGroup1().add(jRadioButton5);
        }
        pack();
        this.setSize(500, 402);
    } 
    catch (Exception e) 
    {
        //add your error handling code here
        e.printStackTrace();
    }
}

private ButtonGroup getButtonGroup1()
{
    if(buttonGroup1 == null) 
    {
        buttonGroup1 = new ButtonGroup();
    }
    return buttonGroup1;
}

public void itemStateChanged(ItemEvent event) 
{
     if( event.getStateChange( ) == ItemEvent.SELECTED)
            subtbox.setText("");
     else if( event.getStateChange( ) == 1)
            subtbox.setText("Cold");
  }

}

View Answers









Related Tutorials/Questions & Answers:
combo boxes
combo boxes  how do you store numbers in the choices. ex. soda is $.75 and tax is $.07 then it equals a new total. I've been trying to use the Itemlistener but i can't figure out how to store the numbers import javax.swing.
values of Combo boxes are not stored in database - JSP-Servlet
values of Combo boxes are not stored in database   i have some combo box values. when i click the submit button after select combo box values...) { document.getElementById('combo').style.visibility = 'hidden'; } } function call
Advertisements
Handling multiple combo boxes of same name - IDE Questions
Handling multiple combo boxes of same name  my code is like this.. i'm...' combo. i want no. of 'csubject' on the browser.. I hope.. i'll get solution
combo box connection
combo box connection  how to provide connection between three combo boxes,if my 1st combo box is course and 2nd combo box is semester and 3rd combo... combo boxes.   Here is Java swing code: import java.sql.*; import
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE] [ ] | | [INCLUDE All
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
ModuleNotFoundError: No module named 'combo'
ModuleNotFoundError: No module named 'combo'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'combo' How to remove the ModuleNotFoundError: No module named 'combo'
ModuleNotFoundError: No module named 'combo'
ModuleNotFoundError: No module named 'combo'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'combo' How to remove the ModuleNotFoundError: No module named 'combo'
JavaScript Dynamic Combo Box
JavaScript Dynamic Combo Box Here we are going to create dynamic combo box. For this, we have created two combo boxes where combo1 represents countries and combo2 represents the cities. The values of the combo boxes are stored
date in combo box
date in combo box  strong texthello, how can i desplay the current year and next year in combo box???!!! it must be uppdate atumaticaly every year>>>
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
ModuleNotFoundError: No module named 'boxes'
ModuleNotFoundError: No module named 'boxes'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'boxes' How to remove the ModuleNotFoundError: No module named 'boxes'
How to create Combo Box in SWT
How to create Combo Box in SWT       This section illustrates you how to create a combo box. In this example, we have created two different combo boxes where one is performing
Disable of Combo - JSP-Servlet
am giving grading facility to the user. Once user selected his grade in combo , the combo should be disabled auotmatically. It should not get enabled at any... combo once grade selected.... pleas help me regarding this aspect.... Thanks
Combo Box - Struts
Combo Box  I hava acombo box cnnected to my database via html collections. When selecting an option, i want to display specific parts (sectons) on my web page....am trying to use logic:present and logic:empty but its not working
ModuleNotFoundError: No module named 'distribution-combo'
ModuleNotFoundError: No module named 'distribution-combo'  Hi, My... named 'distribution-combo' How to remove the ModuleNotFoundError: No module named 'distribution-combo' error? Thanks   Hi, In your
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
combo box - JSP-Servlet
combo box  I am using a JSP form in which a combobox is given and I want to populate data in it from database and on the basis of yhe selected item I want to display related data in a textbox  Hi Friend, Create
Loading combo box from oracle
Loading combo box from oracle  how can i load values into a combobox from oracle database when a value is selected in another combo box
combo program - Java Beginners
combo program  I want to give DOB in combo box for that i have to give 1 to 30 for days and 1900 to 2010. Without giving all, using for loop i have to get the values. Please help me..   Hi Friend, Please visit
populating the combo box - Struts
populating the combo box  Hi I am having problem populating the combo box with a table in MS SQL Server 2005 Management Studio Express. Belo is the extract from the Struct?jsp application. Sector
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click... on the second window and click confirm i would have the information on the combo box. i... combo; JTextField txtBox; private String PersonViewing; private String
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head>
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head> <script language
jtable combo - Java Beginners
jtable combo  i am using jtable (using defaulttablemodel) ,when i am click on a particular cell of jtable i want to display the combo box in that cell,plz provide program  Hi Friend, Try the following code: import
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
ModuleNotFoundError: No module named 'django-boxes'
ModuleNotFoundError: No module named 'django-boxes'  Hi, My Python... 'django-boxes' How to remove the ModuleNotFoundError: No module named 'django-boxes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ensemble-boxes'
ModuleNotFoundError: No module named 'ensemble-boxes'  Hi, My... named 'ensemble-boxes' How to remove the ModuleNotFoundError: No module named 'ensemble-boxes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'little-boxes'
ModuleNotFoundError: No module named 'little-boxes'  Hi, My Python... 'little-boxes' How to remove the ModuleNotFoundError: No module named 'little-boxes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'map-boxes'
ModuleNotFoundError: No module named 'map-boxes'  Hi, My Python... 'map-boxes' How to remove the ModuleNotFoundError: No module named 'map-boxes' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pinax-boxes'
ModuleNotFoundError: No module named 'pinax-boxes'  Hi, My Python... 'pinax-boxes' How to remove the ModuleNotFoundError: No module named 'pinax-boxes' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'adaptive-boxes'
ModuleNotFoundError: No module named 'adaptive-boxes'  Hi, My... named 'adaptive-boxes' How to remove the ModuleNotFoundError: No module named 'adaptive-boxes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-boxes'
ModuleNotFoundError: No module named 'django-boxes'  Hi, My Python... 'django-boxes' How to remove the ModuleNotFoundError: No module named 'django-boxes' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ensemble-boxes'
ModuleNotFoundError: No module named 'ensemble-boxes'  Hi, My... named 'ensemble-boxes' How to remove the ModuleNotFoundError: No module named 'ensemble-boxes' error? Thanks   Hi, In your python
Dojo Combo Box
Dojo Combo Box          In this section, you will learn what is combo box and how to create a combo box in dojo. For creating the Combo box  you need "
How to cascade two text boxes??
How to cascade two text boxes??  I am having 3 text boxes if i entered the value in the first text box then the values of the two text boxes should come from the database with respect to first text box value
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need of some help, so i have three combo boxes, the first is supplier, the second... combo box which will then load the next combo box values, now i know how
Retrieving Data from Database to fill Combo Box
Retrieving Data from Database to fill Combo Box  Sir, I have a JSP Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting
Combo box value Error - WebSevices
Combo box value Error   if($_SERVER['REQUEST_METHOD'] == 'POST' ) { $visa =trim($_POST['hdVisa']); } document.frmProposal.hdVisa.value = document.getElementById('cmbVisa').value; Error
how to create a combo box in html
how to create a combo box in html  <tr> <td>Number<span class=mandatory>*</span></td> <td> <select name="number" id="course" style="width:158px;"> <option value="none">----Select
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically loaded with only district corresponding to "selected state "....and 3rd combo
Combo Box operation in Java Swing
Combo Box operation in Java Swing   ... the Combo Box component, you will learn how to add items to the combo box, remove items from the combo box. This program shows a text field, a combo box
ModuleNotFoundError: No module named 'country-bounding-boxes'
ModuleNotFoundError: No module named 'country-bounding-boxes'  Hi...: No module named 'country-bounding-boxes' How to remove the ModuleNotFoundError: No module named 'country-bounding-boxes' error? Thanks   Hi

Ads