What collection to use?
From my GUI press "Used Phone Acquisition" when enter is pressed the data will be saved and return to "select option".
Am i going to use queue or vector? and how to add
tf1.setText("");to EventHandler Cancel and Cancel2 to terminate data entry.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
publicclass HPhoneInvextends JFrame{
privateint currentCard = 1;
private JPanel cardPanel;
private CardLayout cl;
JPanel card1 =null;
JPanel card2 =null;
JPanel card3 =null;
public HPhoneInv(){
setTitle("Handphone Inventory System");
setSize(500, 160);
cardPanel =new JPanel(new CardLayout());
JPanel jp1 =new JPanel();
jp1.setLayout(new GridLayout(1,1) );
JLabel jl1 =new JLabel("Select Option:");
jl1.setForeground(Color.RED);
jp1.add(jl1);
JPanel buttonPanel =new JPanel();
buttonPanel.setLayout(new GridLayout(1,2) );
JButton AcqBtn=new JButton("Used Phone Acquisition");
JButton TranBtn=new JButton("Sale Transaction");
buttonPanel.add(AcqBtn);
buttonPanel.add(TranBtn);
card1 =new JPanel(new BorderLayout());
card1.add(jp1, BorderLayout.NORTH);
card1.add(buttonPanel, BorderLayout.SOUTH);
card2 =new JPanel(new BorderLayout());
JPanel jp2 =new JPanel();
jp2.setLayout(new GridLayout(5,2) );
JLabel lbl1 =new JLabel("Cust IC No:");
JLabel lbl2=new JLabel("Brand:");
JLabel lbl3 =new JLabel("Model:");
JLabel lbl4=new JLabel("Serial No:");
JLabel lbl5=new JLabel("Cost:");
JTextField tf1=new JTextField("");
JTextField tf2=new JTextField("");
JTextField tf3=new JTextField("");
JTextField tf4=new JTextField("");
JTextField tf5=new JTextField("");
jp2.add(lbl1);
jp2.add(tf1);
jp2.add(lbl2);
jp2.add(tf2);
jp2.add(lbl3);
jp2.add(tf3);
jp2.add(lbl4);
jp2.add(tf4);
jp2.add(lbl5);
jp2.add(tf5);
JPanel buttonPanel2 =new JPanel();
buttonPanel2.setLayout(new GridLayout(1,2) );
JButton EnterBtn=new JButton("Enter");
JButton CancelBtn=new JButton("Cancel");
buttonPanel2.add(EnterBtn);
buttonPanel2.add(CancelBtn);
card2.add(jp2, BorderLayout.NORTH);
card2.add(buttonPanel2, BorderLayout.SOUTH);
//card 3
card3 =new JPanel(new BorderLayout());
JPanel jp3 =new JPanel();
jp3.setLayout(new GridLayout(4,2) );
JLabel l1 =new JLabel("Serial No:");
JLabel l2 =new JLabel("Model:");
JLabel l3 =new JLabel("Price:");
JTextField t1=new JTextField("");
JTextField t2=new JTextField("");
JTextField t3=new JTextField("");
JTextField t4=new JTextField("");
JButton b =new JButton("Search for Phone Record");
jp3.add(l1);
jp3.add(t1);
jp3.add(b);
jp3.add(t2);
jp3.add(l2);
jp3.add(t3);
jp3.add(l3);
jp3.add(t4);
JPanel buttonPanel3 =new JPanel();
buttonPanel3.setLayout(new GridLayout(1,2) );
JButton Enter2Btn=new JButton("Enter");
JButton Cancel2Btn=new JButton("Cancel");
buttonPanel3.add(Enter2Btn);
buttonPanel3.add(Cancel2Btn);
card3.add(jp3, BorderLayout.NORTH);
card3.add(buttonPanel3, BorderLayout.SOUTH);
cardPanel.add(card1,"one");
cardPanel.add(card2,"two");
cardPanel.add(card3,"three");
this.getContentPane().add(cardPanel);
AcqBtn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"two");
}
});
TranBtn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"three");
}
});
EnterBtn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"one");
}
});
CancelBtn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"one");
}
});
Enter2Btn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"one");
}
});
Cancel2Btn.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent arg0){
CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
cardLayout.show(cardPanel,"one");
}
});
}
publicstaticvoid main(String[] args){
HPhoneInv cl =new HPhoneInv();
cl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cl.pack();
cl.setVisible(true);
}
}
Message was edited by:
RockmanEXE
Message was edited by:
RockmanEXE

