View Single Post
  #1 (permalink)  
Old 03-03-2008, 01:26 PM
Lehane_9 Lehane_9 is offline
Member
 
Join Date: Dec 2007
Posts: 6
Lehane_9 is on a distinguished road
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

}


}
}
Reply With Quote
Sponsored Links