Hi,
i have a Java computer shop assignment, a user selects the components he/she requires for a laptop or desktop and then presses the submit button where the total price is calculated and displayed to the user.
I have hard coded the prices for each component in a table, but am unsure as to how to "get" the users selections and how to add the prices up? or how to put that into code rather.
[code]
package ecsecomputers;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;
/**
*
* @author mandy
*/
public class ShopFrame extends javax.swing.JFrame {
/** Creates new form ShopFrame */
public ShopFrame() {
initComponents();
}
// @SuppressWarnings("unchecked")Netbeans GENERATED CODE HERE
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"Intel", "Core II Duo", "2200", "54.99", "Intel ", "Centrino", "1800", "149,99"},
{"Intel", "Quad Core", "3000", "179.99", "Intel ", "Centrino II", "2000", "179.99"},
{"Intel", "Pentium", "1800", "47.99", "Intel", "Core i3", "2200", "165.99"},
{"Intel", "Celeron", "1800", "34.99", "Intel ", "Core i5", "2200", "176.99"},
{"Intel", "Atom", "1400", "68.99", "Intel ", "Core i7", "2800", "199.99"},
{"AMD", "Phenom", "3000", "123.99", "AMD", "Turion II Dual Core", "2000", "145.99"},
{"AMD", "Athlon", "3000", "99.95", "AMD", "Athlon II Dual Core", "2400", "148.95"},
{"AMD", "Sempron", "2000", "38.99", "AMD", "V Series", "1800", "165.99"},
{"HARDDISKS"},
{"Samsung ", "500GB Serial ATA", "7200 rpm", "55.00"},
{"Hitachi ", "1TB External", "7200 rpm", "123.99"},
{"MEMORY", "", null, null, null, null, null, null},
{"Kingston", "1GB DDRII", "1066", "25.99"},
{"Corsair", "1GB DDRII", "1333", "23.99"l},
{"Crucial", "1GB DDR3", "1333", "30.99"},
{"MOTHERBOARDS"},
{"Gigabyte", "Intel LGA775", "", "78.99"},
{"Asus", "AMD AM3", "", "84.99"},
{"DVD-REWRITER"},
{"Samsung", "Internal", null, "24.99"},
{"Sony", "External", null, "60.99"},
{"PSU"},
{"Antec", "650w", null, "73.99"},
{"CASES"},
{"Antec", "ATX", null, "56.99"},
{"Coolermaster", "ATX", null, "76.99"},
{"GRAPHICS CARDS"},
{"Asus", "ATI ", "", "105.00"},
{"Pny", "Nvidia Geforce", null, "159.99"},
{"SOUND CARDS"},
{"Creative ", "Soundblaster 5.1 vx", null, "15.99"},
{"Creative ", "Soundblaster XFI", null, "38.99"},
{"HEATSINKS"},
{"Thermaltake", "Intel LGA755", "", "25.95"},
{"Coolermaster", "AMD AM2 AM3", null, "23.99},
},
new String [] { "Brand", "Type", "Speed GHz", "Price £", "Brand", "Type", "Speed GHz", "Price £" }
));
jTable1.setName("jTable1");
jScrollPane1.setViewportView(jTable1);
private void bSubmitActionPerformed(java.awt.event.ActionEvent evt) {
//TO DO CODE HERE
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new ShopFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
javax.swing.JLabel TitleLB;
javax.swing.JButton bSubmit;
javax.swing.JComboBox cbDeskprocessor;
javax.swing.JComboBox cbDesktopspeed;
javax.swing.JComboBox cbLaptopcpu;
javax.swing.JComboBox cbLaptopspeed;
javax.swing.JFormattedTextField jFormattedTextField1;
javax.swing.JLabel jLabel1;
javax.swing.JLabel jLabel2;
javax.swing.JScrollPane jScrollPane1;
javax.swing.JScrollPane jScrollPane2;
javax.swing.JSeparator jSeparator1;
javax.swing.JTable jTable1;
javax.swing.JTextArea jTextArea1;
javax.swing.JLabel lbDesktopcpu;
javax.swing.JLabel lbLaptopcpu;
javax.swing.JLabel lbProcessorspeed1;
javax.swing.JLabel lbProcessorspeed2;
javax.swing.JMenuBar menuBar;
javax.swing.JMenu muAboutus;
javax.swing.JMenu muComponents;
javax.swing.JMenu muContact;
javax.swing.JMenu muDesktop;
javax.swing.JMenu muHelp;
javax.swing.JMenu muHome;
javax.swing.JMenu muIndex;
javax.swing.JMenu muLaptop;
javax.swing.JMenu muShoppingcart;
javax.swing.JPanel pCpupanel;
javax.swing.JRadioButtonMenuItem rbDeskcase;
javax.swing.JRadioButtonMenuItem rbDeskchipset;
javax.swing.JRadioButtonMenuItem rbDeskcpu;
javax.swing.JRadioButtonMenuItem rbDeskdvdrewriter;
javax.swing.JRadioButtonMenuItem rbDeskgraphics;
javax.swing.JRadioButtonMenuItem rbDeskheatsink;
javax.swing.JRadioButtonMenuItem rbDeskmemory;
javax.swing.JRadioButtonMenuItem rbDeskmonitor;
javax.swing.JRadioButtonMenuItem rbDeskmotherboard;
javax.swing.JRadioButtonMenuItem rbDeskpsu;
javax.swing.JRadioButtonMenuItem rbDesksound;
javax.swing.JRadioButtonMenuItem rbLapbattery;
javax.swing.JRadioButtonMenuItem rbLapcase;
javax.swing.JRadioButtonMenuItem rbLapchassis;
javax.swing.JRadioButtonMenuItem rbLapchipset;
javax.swing.JRadioButtonMenuItem rbLapcpu;
javax.swing.JRadioButtonMenuItem rbLapdvdrewriter;
javax.swing.JRadioButtonMenuItem rbLapgraphicscard;
javax.swing.JRadioButtonMenuItem rbLapharddisk;
javax.swing.JRadioButtonMenuItem rbLapheatsink;
javax.swing.JRadioButtonMenuItem rbLapkeyboard;
javax.swing.JRadioButtonMenuItem rbLapmotherboard;
javax.swing.JRadioButtonMenuItem rbLapscreen;
javax.swing.JRadioButtonMenuItem rbLapsoundcard;
// End of variables declaration
}