Solved

Multiple JPanel in JApplet

Posted on 2007-11-21
2
1,135 Views
Last Modified: 2013-11-23
This should be a simple task, but I don't do that much with Java.

5 different JPanel classes which handle their own actions have been created.  For this conversation we will call them MyPanel1 ... MyPanel 5.  The first of these is a button/keypad menu.  All of this must run within a JApplet.  When the user selects one of the buttons a new class instance is created of the appropriate class and becomes the content for the JApplet.  When the user wishes to exit that JPanel they chose an exit option and it finalizes.  The JApplet should redisplay the original menu JPanel class (MyPanel1 for this discussion).

Need to see a code snippet for the switching back and forth.

0
Comment
Question by:yyyc186
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20331805
a CardLayout can be used for easily switching between panels
0
 
LVL 7

Accepted Solution

by:
UrosVidojevic earned 250 total points
ID: 20331824
In my opinion, in this case it is the most appropriate to use CardLayout class, to realize that kind of panel switching.

You should have one main panel with 5 panels added to it using CardLayout. Initialy MyPanel1 instance will be visible. When user choose some button from MyPanel1, main panel will switch its content to appropriate panel. When user wants to return to MyPanel1, clicking the appropriate "exit" button will make MyPanel1 visible again.

Examples:
1.) http://www.science.uva.nl/ict/ossdocs/java/tutorial/ui/layout/card.html
2.) http://www.javareference.com/jrexamples/viewexample.jsp?id=28
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now