File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JPanel and JFrame listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel and JFrame listener" Watch "JPanel and JFrame listener" New topic
Author

JPanel and JFrame listener

Kah Fai Tan
Greenhorn

Joined: Jun 16, 2007
Posts: 3
Hi,

Currently, I am doing a program. I will have few JPanel and only one JFrame.

By default, JFrame will show a JPanel (Panel A), in full screen.

I implement a button in Panel A to call the Panel B.

How am I to realize this coding?

Panel A will be either remove or disappear from the JFrame and add Panel B into the JFrame.

Thank you
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Kah Fai Tan,
Welcome to the Ranch.

Check out card layout.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Look up the Sun Swing tutorial on CardLayout.
Kah Fai Tan
Greenhorn

Joined: Jun 16, 2007
Posts: 3
That means I need to create a JButton with the listener on JFrame, I only be able to switch the JPanel?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

The button will be the trigger for the switching action. Yes. But the button need not be the only trigger. You can have a menu based trigger, or a keyboard based trigger or even a mouse based trigger. It all depends on what your requirement is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel and JFrame listener
 
Similar Threads
JTable serialization problem
How to draw an etched line?
Image is not been added to a label
JTable rows are getting visible in the middile of the JFrame only
printing jframe content in core java