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, 03:07 PM
Member
 
Join Date: Dec 2007
Posts: 6
Lehane_9 is on a distinguished road
Cannot understand whats wrong
I dont know why my new panel called welcome will noy open can anybody please help.

First JFrame is this
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;
JPanel cardHolder;
CardLayout card;
Container c;
Example_22_2 panelmgr;





public Example_22_2(Example_22_2 panelmgr)
{
super("Irish Rail Timetabling and Ticketing System ");
cardHolder=new JPanel();
card=new CardLayout();
cardHolder.setLayout(card);

c=getContentPane();

welcome panel1 = new welcome(this);
// adminLogIn panel2 = new adminLogIn(this);

cardHolder.add(panel1, "panel1",1);
//cardHolder.add(panel2,"panel2",1);


loginBtn =new JButton("Login change timetables");
viewTimeTablesBtn = new JButton("View Timetables");
BuyTicketsBtn = new JButton ("Buy tickets");


loginBtn.addActionListener(this);
viewTimeTablesBtn.addActionListener(this);
BuyTicketsBtn.addActionListener(this);


c.add(loginBtn);
c.add(viewTimeTablesBtn);
c.add(BuyTicketsBtn);


setSize (250, 200);
show();
}

public static void main (String args[])
{
Example_22_2 example = new Example_22_2();
}

public void changePanel(String in)
{
card.show(cardHolder,in);
}

public void actionPerformed(ActionEvent e)
{


if(e.getSource()==viewTimeTablesBtn)
{
panelmgr.changePanel("panel1");


}


}
}



Then welcome.java is

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class welcome extends JPanel implements ActionListener


{

private JCheckBox cd1Cbx;
private JButton resetBtn;

private Container c;


public welcome()
{

c.add(cd1Cbx);
c.add(resetBtn);

}
public void actionPerformed(ActionEvent e)
{




}


}

I dont know why it wont work. any help greatly appreciated
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2008, 08:57 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class E22_2 extends JFrame implements ActionListener { private JButton loginBtn, viewTimeTablesBtn, BuyTicketsBtn; JPanel cardHolder; CardLayout card; Container c; public E22_2() { super("Irish Rail Timetabling and Ticketing System "); cardHolder=new JPanel(); card=new CardLayout(); cardHolder.setLayout(card); c=getContentPane(); Welcome panel1 = new Welcome(this); // adminLogIn panel2 = new adminLogIn(this); cardHolder.add("welcome", panel1); // cardHolder.add("admin", panel2); loginBtn =new JButton("Login change timetables"); viewTimeTablesBtn = new JButton("View Timetables"); BuyTicketsBtn = new JButton ("Buy tickets"); loginBtn.addActionListener(this); viewTimeTablesBtn.addActionListener(this); BuyTicketsBtn.addActionListener(this); System.out.println("JFrame default layout manager = " + getLayout().getClass().getName()); // no constraint -> default center section c.add(cardHolder); JPanel buttonPanel = new JPanel(); buttonPanel.add(loginBtn); buttonPanel.add(viewTimeTablesBtn); buttonPanel.add(BuyTicketsBtn); c.add(buttonPanel, "South"); setSize (450, 200); setVisible(true); } public static void main (String args[]) { new E22_2(); } public void changePanel(String in) { card.show(cardHolder, in); } public void actionPerformed(ActionEvent e) { if(e.getSource()==viewTimeTablesBtn) { changePanel("welcome"); } } } class Welcome extends JPanel implements ActionListener { private JCheckBox cd1Cbx = new JCheckBox("checkBox"); private JButton resetBtn = new JButton("reset"); // private Container c; public Welcome(E22_2 e) { add(cd1Cbx); add(resetBtn); } public void actionPerformed(ActionEvent e) { } }
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
Errors I don't understand MattyB New To Java 4 04-02-2008 12:55 AM
New: Want to understand Drawing... diRisig New To Java 1 02-05-2008 09:13 AM
i don understand this error Deon New To Java 4 01-12-2008 11:03 AM
Whats wrong with my code??? Soda New To Java 2 12-06-2007 01:54 PM
whats the difference between Java core,J2EE...... prince24 New To Java 2 07-11-2007 07:54 PM


All times are GMT +3. The time now is 12:46 AM.


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