Create frame inside an EventListener
An example when Installing a programme(WinZip)
There will be Next ,Previous and Cancel buttons .When you pressed Next , the Frame will retain but the content will be different, not popping out a new window and ended up with lots of window when u finish installing.
The project i'm doing is similar to the example above.
-A main menu with 2 JButton
-when option is selected it will bring you to that page where u key in your name,Handphone numbers.etc and Enter and Cancel button below.
-Canceling will bring you back to main menu.
Note :This project does not use tab, toolbar and internalframe and not Applet but GUI.
From my code,
Create a new class and put it inside ActionListener?
Create Frame inside EventListener?
How?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class HPhoneInv extends JFrame
{
private JLabel lbl1;
private JButton bAcq,bTran;
private JPanel p1,p2;
public static void main(String args[])
{
HPhoneInv hp=new HPhoneInv();
}
public HPhoneInv()
{
setTitle("Handphone Inventory System");
setLayout(new GridLayout(2,1) );
setResizable(true);
p1=new JPanel();
p1.setLayout(new GridLayout(5,1) );
JLabel lbl1=new JLabel("Select Option:");
p1.add(lbl1);
p2=new JPanel();
p2.setBackground(Color.white);
p2.setLayout(new GridLayout(1,2) );
bAcq=new JButton("Used Phone Acquisition");
bTran=new JButton("Sale Transaction");
p2.add(bAcq);
p2.add(bTran);
add(p1,"North");
add(p2,"South");
pack();
setVisible(true);
bAcq.addActionListener(new AcqHandler() );
bTran.addActionListener(new TranHandler() );
}
class AcqHandler implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
}
}
class TranHandler implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
}
}
}

