call GUI constructor
Can someone please tell me how to call this GUI constructor?
/*
* MenuGUI3.java
*
* Created on June 21, 2007, 8:13 PM
*/
/**
*
* @author pberardi
*/
publicclass MenuGUI3extends javax.swing.JPanel{
int total1;
/** Creates new form MenuGUI3 */
public MenuGUI3(){
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
privatevoid initComponents(){
sugarButton =new javax.swing.JButton();
extraSugarButton =new javax.swing.JButton();
creamerButton =new javax.swing.JButton();
extraCreamerButton =new javax.swing.JButton();
largeCoffeeButton =new javax.swing.JButton();
smallCoffeButton =new javax.swing.JButton();
depositFiveCentsButton =new javax.swing.JButton();
depositTenCentsButton =new javax.swing.JButton();
depositTwentyFiveCentsButton =new javax.swing.JButton();
submitButton =new javax.swing.JButton();
saveOrderButton =new javax.swing.JButton();
readOrderButton =new javax.swing.JButton();
buttonSelected =new javax.swing.JLabel();
totalDeposited =new javax.swing.JLabel();
sugarButton.setText("Sugar");
sugarButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
sugarButtonActionPerformed(evt);
}
});
extraSugarButton.setText("Extra Sugar");
extraSugarButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
extraSugarButtonActionPerformed(evt);
}
});
creamerButton.setText("Creamer");
creamerButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
creamerButtonActionPerformed(evt);
}
});
extraCreamerButton.setText("Extra Creamer");
extraCreamerButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
extraCreamerButtonActionPerformed(evt);
}
});
largeCoffeeButton.setText("Large Coffee");
largeCoffeeButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
largeCoffeeButtonActionPerformed(evt);
}
});
smallCoffeButton.setText("Small Coffee");
smallCoffeButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
smallCoffeButtonActionPerformed(evt);
}
});
depositFiveCentsButton.setText("Deposit 5 Cents");
depositFiveCentsButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
depositFiveCentsButtonActionPerformed(evt);
}
});
depositTenCentsButton.setText("Deposit 10 Cents");
depositTenCentsButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
depositTenCentsButtonActionPerformed(evt);
}
});
depositTwentyFiveCentsButton.setText("Deposit 25 Cents");
depositTwentyFiveCentsButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
depositTwentyFiveCentsButtonActionPerformed(evt);
}
});
submitButton.setText("Submit");
submitButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
submitButtonActionPerformed(evt);
}
});
saveOrderButton.setText("Save Order");
saveOrderButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
saveOrderButtonActionPerformed(evt);
}
});
readOrderButton.setText("Read Order");
readOrderButton.addActionListener(new java.awt.event.ActionListener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
readOrderButtonActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout =new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(26, 26, 26)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(largeCoffeeButton)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(readOrderButton)
.add(smallCoffeButton))))
.add(layout.createSequentialGroup()
.add(48, 48, 48)
.add(buttonSelected))
.add(layout.createSequentialGroup()
.add(37, 37, 37)
.add(totalDeposited)))
.add(51, 51, 51)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(depositTenCentsButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
.add(layout.createSequentialGroup()
.add(depositFiveCentsButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.add(depositTwentyFiveCentsButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
.add(88, 88, 88)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(sugarButton)
.add(creamerButton)
.add(extraSugarButton)
.add(extraCreamerButton)))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(saveOrderButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 76, Short.MAX_VALUE)
.add(submitButton)))
.add(140, 140, 140))
);
layout.linkSize(new java.awt.Component[]{creamerButton, extraCreamerButton, extraSugarButton, sugarButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
layout.linkSize(new java.awt.Component[]{depositFiveCentsButton, depositTenCentsButton, depositTwentyFiveCentsButton, largeCoffeeButton, readOrderButton, saveOrderButton, smallCoffeButton, submitButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(23, 23, 23)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(largeCoffeeButton)
.add(depositFiveCentsButton)
.add(sugarButton))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(38, 38, 38)
.add(smallCoffeButton))
.add(layout.createSequentialGroup()
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(depositTenCentsButton)
.add(extraSugarButton))))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(depositTwentyFiveCentsButton)
.add(creamerButton))
.add(23, 23, 23)
.add(extraCreamerButton))
.add(layout.createSequentialGroup()
.add(54, 54, 54)
.add(buttonSelected)
.add(29, 29, 29)
.add(totalDeposited)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 59, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(readOrderButton)
.add(submitButton)
.add(saveOrderButton))
.add(24, 24, 24))
);
layout.linkSize(new java.awt.Component[]{creamerButton, extraCreamerButton, extraSugarButton, sugarButton}, org.jdesktop.layout.GroupLayout.VERTICAL);
}// </editor-fold>
privatevoid readOrderButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
OrderHistory.readOrders();
}
privatevoid smallCoffeButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select small coffee button");
Menu menu = Menu.getInstance();
menu.selectSmallCoffee();
}
privatevoid largeCoffeeButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select large coffee button");
Menu menu = Menu.getInstance();
menu.selectLargeCoffee();
}
privatevoid submitButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the submit button");
// done =true;
Payment p =new Payment();
p.computePayment(ScenarioSteps.SEL_LARGE_COFFEE);
CoinBank cb = CoinBank.getInstance();
cb.insertCoin(100,p);
int userCents = 0;
int totalCents=0;
do{
//System.out.println("Enter number of cents, -1 to terminate");
totalDeposited.setText("Depositing 100 cents please");
// userCents = input.nextInt();
if(total1<100)
totalCents+=total1;
}
while (total1 <100);
if(totalCents==0)
totalCents+=total1;
p.setPaidInfull();
// p.setPaidInfull();
Menu menu = Menu.getInstance();
menu.selectDone();
menu.clearOrder();
}
privatevoid smallCoffeeActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select small coffee button");
Menu menu = Menu.getInstance();
menu.selectSmallCoffee();
}
privatevoid largeCoffeeActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select large coffee button");
Menu menu = Menu.getInstance();
menu.selectLargeCoffee();
}
privatevoid depositTwentyFiveCentsButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
total1 = total1 + 25;
totalDeposited.setText("total deposited is " + total1 +" cents");
buttonSelected.setText("You just clicked the twenty-five cent button");
}
privatevoid depositTenCentsButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
total1 = total1 + 10;
totalDeposited.setText("total deposited is " + total1 +" cents");
buttonSelected.setText("You just clicked the ten cent button");
}
privatevoid depositFiveCentsButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
total1 = total1 + 5;
totalDeposited.setText("total deposited is " + total1 +" cents");
buttonSelected.setText("You just clicked the five cent button");
}
privatevoid saveOrderButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
OrderHistory.saveAllOrders();
}
privatevoid extraCreamerButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select extra creamer button");
Menu menu = Menu.getInstance();
menu.selectCreamer();
}
privatevoid creamerButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select creamer button");
Menu menu = Menu.getInstance();
menu.selectCreamer();
}
privatevoid extraSugarButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select extra sugar button");
Menu menu = Menu.getInstance();
menu.selectExtraSugar();
}
privatevoid sugarButtonActionPerformed(java.awt.event.ActionEvent evt){
// TODO add your handling code here:
buttonSelected.setText("You just clicked the select sugar button");
Menu menu = Menu.getInstance();
menu.selectSugar();
}
// Variables declaration - do not modify
private javax.swing.JLabel buttonSelected;
private javax.swing.JButton creamerButton;
private javax.swing.JButton depositFiveCentsButton;
private javax.swing.JButton depositTenCentsButton;
private javax.swing.JButton depositTwentyFiveCentsButton;
private javax.swing.JButton extraCreamerButton;
private javax.swing.JButton extraSugarButton;
private javax.swing.JButton largeCoffeeButton;
private javax.swing.JButton readOrderButton;
private javax.swing.JButton saveOrderButton;
private javax.swing.JButton smallCoffeButton;
private javax.swing.JButton submitButton;
private javax.swing.JButton sugarButton;
private javax.swing.JLabel totalDeposited;
// End of variables declaration
}

