Commit b5bd852d authored by robert.sharp's avatar robert.sharp

Finalised the quantity selector.

parent c24c9af2
......@@ -94,7 +94,7 @@ public class temp extends javax.swing.JFrame {
quantLabelchange.setText("Selected quantity:");
quantBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1", "2", "3", "4", "5" }));
quantBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select a value", "1", "2", "3", "4", "5" }));
quantBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
quantBoxActionPerformed(evt);
......@@ -306,7 +306,12 @@ public class temp extends javax.swing.JFrame {
private void quantBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
findItem();
quant = Double.parseDouble(quantBox.getSelectedItem().toString()) /2;
if (quantBox.getSelectedItem().toString()=="Select a value"){
error.setText("Please select an quantity;");
} else {
quant = Double.parseDouble(quantBox.getSelectedItem().toString()) /2;
}
//find the slected item and convet it into a double
quantLabelchange.setText("Selected quantity: "+(quant*2));
//update the display to show the quanity of item
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment