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

Update temp.java

parent b8ad60cb
......@@ -30,6 +30,7 @@ public class temp extends javax.swing.JFrame {
static String Chosen = "";
static String Price = "";
static double quant = 0;
static int index = 0;
public temp() {
......@@ -50,9 +51,9 @@ public class temp extends javax.swing.JFrame {
jLabel1 = 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();
quantBox = new javax.swing.JComboBox<>();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
......@@ -65,13 +66,56 @@ public class temp extends javax.swing.JFrame {
jLabel1.setText("Select Item Here:");
PriceLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
PriceLabel.setText("Please Select an Item;");
quantLabel.setText("Input Quanity:");
quantLabelchange.setText("Selected quantity:");
quantBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "0", "1", "2", "3", "4", "5" }));
quantBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
quantBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(quantLabelchange, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(quantLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
.addComponent(quantBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(44, Short.MAX_VALUE)
.addComponent(quantLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(quantBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11)
.addComponent(quantLabelchange)
.addGap(28, 28, 28))
);
javax.swing.GroupLayout ItemSelectLayout = new javax.swing.GroupLayout(ItemSelect);
ItemSelect.setLayout(ItemSelectLayout);
ItemSelectLayout.setHorizontalGroup(
ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ItemSelectLayout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
......@@ -79,11 +123,10 @@ public class temp extends javax.swing.JFrame {
.addGap(22, 22, 22))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemSelectLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(PriceLabel)
.addContainerGap())
.addContainerGap())))
);
ItemSelectLayout.setVerticalGroup(
ItemSelectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
......@@ -94,45 +137,9 @@ public class temp extends javax.swing.JFrame {
.addComponent(ItemSelectBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(PriceLabel)
.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))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
......@@ -141,17 +148,13 @@ public class temp extends javax.swing.JFrame {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.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))
.addContainerGap(303, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.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))
.addComponent(ItemSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
......@@ -192,18 +195,19 @@ public class temp extends javax.swing.JFrame {
PriceLabel.setText("Please selct an Item");
} else {
PriceLabel.setText("Price: " + Price);
}
//update price label
}//GEN-LAST:event_ItemSelectBoxActionPerformed
private void QuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuantityActionPerformed
private void quantBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quantBoxActionPerformed
// TODO add your handling code here:
//selecting the quanity of items
quant = Double.parseDouble(Quantity.getSelectedItem().toString());
quant = Double.parseDouble(quantBox.getSelectedItem().toString());
quantLabelchange.setText("Selected quantity: " + quant);
}//GEN-LAST:event_QuantityActionPerformed
quantLabelchange.setText("Selected quantity: "+quant);
}//GEN-LAST:event_quantBoxActionPerformed
/**
* @param args the command line arguments
......@@ -239,17 +243,23 @@ public class temp extends javax.swing.JFrame {
});
}
public void removeItem(){
public void findItem(){
index = -1;
for (int i=0;i<itemCode.length;i++) {
if (itemCode[i].equals(ID)) {
index = i;
break;
}
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel ItemSelect;
private javax.swing.JComboBox<String> ItemSelectBox;
private javax.swing.JLabel PriceLabel;
private javax.swing.JComboBox<String> Quantity;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JComboBox<String> quantBox;
private javax.swing.JLabel quantLabel;
private javax.swing.JLabel quantLabelchange;
// 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