if you wont to create a program with more than one Frame ..
then this is very simple code doing that ...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GUIFrame extends JFrame{
private JButton NextFrame, LastFrame;
private JLabel Next, Previous;
private Container FirstPage, SeconPage;
public GUIFrame() {
// set buttons
NextFrame = new JButton("NextFrame");
LastFrame = new JButton("LastFrame");
setActionListener(NextFrame);
setActionListener(LastFrame);
// set Label
Next = new JLabel("Go to Next Frame");
Previous = new JLabel("Go to Previous Frame");
setJLabel(Next);
setJLabel(Previous);
// set Container
//FirstPage
FirstPage = new Container();
//SeconPage
SeconPage = new Container();
//start
setFirstPage();
}
//method to set a setActionListener to the button-----------------------------
private void setActionListener(JButton Button)
{
String Name = Button.getText();
Button.setName(Name);
Button.setActionCommand(Name);
Button.addActionListener(//S1
new ActionListener(){//S2
public void actionPerformed (ActionEvent event)
{
setFrame(event.getActionCommand());
}
} //E2
);//E1
}// end method setActionListener
//method to set JLabel--------------------------------------------------------
private void setJLabel(JLabel Label)
{
Label.setFont(new Font("",Font.PLAIN,13)); // set the font and Size
//Label.setHorizontalAlignment(SwingConstants.CENTER); // in the Center
}// end method setJLabel
//method to select Frame to display-------------------------------------------
private void setFrame(String FrameName)
{
if(FrameName.compareTo(NextFrame.getText())==0)
{ setSeconPage(); }
else
{ setFirstPage(); }
}//end method setFrame
// method to set teh first page-----------------------------------------------
private void setFirstPage()
{
getContentPane().removeAll();
getContentPane().repaint();
FirstPage = getContentPane();
FirstPage.add(Next,BorderLayout.WEST);
FirstPage.add(NextFrame,BorderLayout.EAST);
setLocation(250,300); // the frame location
setSize(260,100);// the size
setVisible(true);
}// end method setFirstPage
//method to set the second page-----------------------------------------------
private void setSeconPage()
{
getContentPane().removeAll();
getContentPane().repaint();
SeconPage = getContentPane();
SeconPage.add(Previous,BorderLayout.WEST);
SeconPage.add(LastFrame,BorderLayout.EAST);
setLocation(350,300);
setSize(260,100);
setVisible(true);
}// end method setSeconPage
}the above code is simple sample of how to do more than one Frame...
and if any question ... just aske ..