Share on Google+Share on Google+

joseph merriex
combo boxes
0 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners

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();

public BurgeMenu() {

private void initGUI() {
    try {
            jLabel1 = new JLabel();
            jLabel1.setBounds(204, 0, 125, 30);
            jLabel2 = new JLabel();
            jLabel2.setBounds(24, 43, 90, 16);
            jLabel3 = new JLabel();
            jLabel3.setBounds(24, 76, 129, 16);
            jLabel4 = new JLabel();
            jLabel4.setBounds(24, 110, 72, 16);
            sprqst = new JTextField();
            sprqst.setBounds(171, 73, 158, 22);
            ComboBoxModel jComboBox1Model = 
                new DefaultComboBoxModel(
                        new String[] { "1.Cheeseburger", "2.Double Cheeseburger","3.Triple Cheeseburger" });
            jComboBox1 = new JComboBox();
            jComboBox1.setBounds(171, 36, 166, 22);
            jLabel5 = new JLabel();
            jLabel5.setBounds(24, 163, 56, 16);
            ComboBoxModel jComboBox2Model = 
                new DefaultComboBoxModel(
                        new String[] { "Small", "Medium","Large" }); 

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

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

public void itemStateChanged(ItemEvent event) 
     if( event.getStateChange( ) == ItemEvent.SELECTED)
     else if( event.getStateChange( ) == 1)



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
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
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
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE] [ ] | | [INCLUDE All
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
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
Label.setText showing square boxes for non english locales
Label.setText showing square boxes for non english locales  Hi, I am using Label.setText to display a value in applets of the application by fetching... are getting displayed as square boxes when locale is passed other than english locale
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
How to Create Pop Up Boxes in JavaScript
How to Create Pop Up Boxes in JavaScript  Hi, I am beginners...,   Hi, In JavaScript you can find three types of pop alert boxes. These are alert, confirm, prompt pop up boxes found in JavaScript. You are asking how
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
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>>>
How to change focus among multiple select boxes?
How to change focus among multiple select boxes?  Hello, I have three select boxes in three divs. All of the select boxes are focused when I click... boxes aren't focused at one click in my example. I have to click twice. Maybe, my
Hide boxes by clicking on it using jQuery
Hide boxes by clicking on it using jQuery In this tutorial , we will discuss about how to hide boxes by clicking on it using jQuery. In the given below example , 30 boxes inside web page are displayed. When we click on any box (among
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
JavaScript Pop Up Boxes
JavaScript Pop Up Boxes JavaScript has three kind of pop-up boxes,  i)    Alert-Box: If some surety is required from the user or an alert message is to generate then we can use alert box, user has to click ok
Check boxes - Java Server Faces Questions
Check boxes  Hi All, In Jsf when i select one item in selectOneMenu it should display check boxes according to our requirement.for Ex:if i select one item state it should display cities in checkboxes.there we have to select
DropDown and text boxes with AJAX, JSP - Ajax
DropDown and text boxes with AJAX, JSP  Hi, we are using one drop down and two text boxes. Drop down values needs to be retrive from one table.we... in the text boxes onblur it needs to validate whether the inserted values
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 trying to use logic:present and logic:empty but its not working
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
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
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
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
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
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: <[email protected] 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: <[email protected] import="java.sql.*"%> <html> <head> <script language
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
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
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
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null