Buttons to show new panels
I have a frame with three buttons, basically i want to know how to get one button to bring to a new pane where i can have new buttons etc, any help would be greatly appreciated. this is what i have
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class Example_22_2 extends JFrame implements ActionListener
{
private JButton loginBtn, viewTimeTablesBtn,BuyTicketsBtn;
Container c;
FlowLayout layout;
public Example_22_2()
{
super("Irish Rail Timetabling and Ticketing System ");
c=getContentPane();
layout= new FlowLayout();
c.setLayout(layout);
loginBtn =new JButton("Login change timetables");
viewTimeTablesBtn = new JButton("View Timetables");
BuyTicketsBtn = new JButton ("Buy tickets");
clearForm = new JButton("Clear");
loginBtn.addActionListener(this);
viewTimeTablesBtn.addActionListener(this);
BuyTicketsBtn.addActionListener(this);
clearForm.addActionListener(this);
c.add(loginBtn);
c.add(viewTimeTablesBtn);
c.add(BuyTicketsBtn);
c.add(clearForm);
setSize (250, 200);
show();
}
public static void main (String args[])
{
Example_22_2 example = new Example_22_2();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==(viewTimeTablesBtn))
{
// I want to go to a new panel
}
}
}