Commit 5e42f4ed authored by robert.sharp's avatar robert.sharp

Update temp.java

parent 47f50a14
...@@ -23,12 +23,13 @@ public class temp extends javax.swing.JFrame { ...@@ -23,12 +23,13 @@ public class temp extends javax.swing.JFrame {
//the code of the items //the code of the items
static String itemName[]={"Chocolate","Water","Drink", "Snack", "Sweet"}; static String itemName[]={"Chocolate","Water","Drink", "Snack", "Sweet"};
//the names of the items //the names of the items
static double basket[]={0, 0, 0, 0, 0};
//setting the default values //setting the default values
static String ID = ""; static String ID = "";
static String Chosen = ""; static String Chosen = "";
static String Price = ""; static String Price = "";
static double quant = 0;
public temp() { public temp() {
...@@ -48,6 +49,10 @@ public class temp extends javax.swing.JFrame { ...@@ -48,6 +49,10 @@ public class temp extends javax.swing.JFrame {
ItemSelectBox = new javax.swing.JComboBox<>(); ItemSelectBox = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
PriceLabel = new javax.swing.JLabel(); PriceLabel = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
Quantity = new javax.swing.JComboBox<>();
quantLabel = new javax.swing.JLabel();
quantLabelchange = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
...@@ -60,15 +65,14 @@ public class temp extends javax.swing.JFrame { ...@@ -60,15 +65,14 @@ public class temp extends javax.swing.JFrame {
jLabel1.setText("Select Item Here:"); jLabel1.setText("Select Item Here:");
PriceLabel.setText("Please Select an Item;");
javax.swing.GroupLayout ItemSelectLayout = new javax.swing.GroupLayout(ItemSelect); javax.swing.GroupLayout ItemSelectLayout = new javax.swing.GroupLayout(ItemSelect);
ItemSelect.setLayout(ItemSelectLayout); ItemSelect.setLayout(ItemSelectLayout);
ItemSelectLayout.setHorizontalGroup( ItemSelectLayout.setHorizontalGroup(
ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ItemSelectLayout.createSequentialGroup() .addGroup(ItemSelectLayout.createSequentialGroup()
.addContainerGap() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ItemSelectLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addComponent(jLabel1) .addComponent(jLabel1)
...@@ -76,9 +80,10 @@ public class temp extends javax.swing.JFrame { ...@@ -76,9 +80,10 @@ public class temp extends javax.swing.JFrame {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()))) .addContainerGap())))
.addGroup(ItemSelectLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(PriceLabel) .addComponent(PriceLabel)
.addGap(0, 0, Short.MAX_VALUE)))) .addContainerGap())
); );
ItemSelectLayout.setVerticalGroup( ItemSelectLayout.setVerticalGroup(
ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
...@@ -89,22 +94,64 @@ public class temp extends javax.swing.JFrame { ...@@ -89,22 +94,64 @@ public class temp extends javax.swing.JFrame {
.addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(PriceLabel) .addComponent(PriceLabel)
.addContainerGap(30, Short.MAX_VALUE)) .addContainerGap(26, Short.MAX_VALUE))
);
Quantity.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "0", "1", "2", "3", "4", "5" }));
Quantity.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
QuantityActionPerformed(evt);
}
});
quantLabel.setText("Select Quanity:");
quantLabelchange.setText("Selected quantity:");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(quantLabelchange, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Quantity, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(quantLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 30, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(quantLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Quantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(quantLabelchange)
.addGap(23, 23, 23))
); );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(0, 279, Short.MAX_VALUE) .addComponent(ItemSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ItemSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(150, 150, 150))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(ItemSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGap(0, 168, Short.MAX_VALUE)) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ItemSelect, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(168, Short.MAX_VALUE))
); );
pack(); pack();
...@@ -150,6 +197,14 @@ public class temp extends javax.swing.JFrame { ...@@ -150,6 +197,14 @@ public class temp extends javax.swing.JFrame {
//update price label //update price label
}//GEN-LAST:event_ItemSelectBoxActionPerformed }//GEN-LAST:event_ItemSelectBoxActionPerformed
private void QuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuantityActionPerformed
// TODO add your handling code here:
//selecting the quanity of items
quant = Double.parseDouble(Quantity.getSelectedItem().toString());
quantLabelchange.setText("Selected quantity: " + quant);
}//GEN-LAST:event_QuantityActionPerformed
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
...@@ -184,11 +239,19 @@ public class temp extends javax.swing.JFrame { ...@@ -184,11 +239,19 @@ public class temp extends javax.swing.JFrame {
}); });
} }
public void removeItem(){
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel ItemSelect; private javax.swing.JPanel ItemSelect;
private javax.swing.JComboBox<String> ItemSelectBox; private javax.swing.JComboBox<String> ItemSelectBox;
private javax.swing.JLabel PriceLabel; private javax.swing.JLabel PriceLabel;
private javax.swing.JComboBox<String> Quantity;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel quantLabel;
private javax.swing.JLabel quantLabelchange;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }
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