Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-03-2008, 01:26 PM
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

}


}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2008, 05:22 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
CardLayout is one way of doing this. You can find out more it here: How to Use CardLayout.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
images, panels and applets jamesfrize Java Applets 3 03-20-2008 05:35 PM
netbeans 6.0 not show commpunent or show blank page fahimaamir NetBeans 1 01-26-2008 07:20 AM
Working with Labels on Panels. vargihate AWT / Swing 2 01-04-2008 05:09 AM
JMenu calling another Forms/Panels plodos New To Java 2 12-10-2007 09:02 AM
Need a tutorial for Studying about Panels ramachandran New To Java 1 10-25-2007 10:05 AM


All times are GMT +3. The time now is 10:07 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org