aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How do you switch JPanels to be shown within the same JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do you switch JPanels to be shown within the same JFrame" Watch "How do you switch JPanels to be shown within the same JFrame" New topic
Author

How do you switch JPanels to be shown within the same JFrame

mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
Ok here is my problem.

How do you switch JPanels to be shown within the same JFrame.
Lets say you have a JFrame including a JPanel showing a menu for ex.
1, show name
2,show lastname
3, show age

If you press 1 you should see names but in the same JFrame as the menu,i don't want it to pop up a new JFrame
with the name (thats what it does nOW), same goes for alt 2 and 3. i know about event handling, i just want to know how to switch between JPanels using the same JFrame.

Please don tell me to go look in API or some other guide on the internet that's just crap, if you know how to slove
this PLEASE POST THE CODE WITH EXPLANATION OTHERWISE DON'T BOTHER TO RESPOND

thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Hello, Mike. I see you have been here a month but you've missed some important points about how the forums work here. Could I draw your attention to these links which suggest good ways to frame your post?

UseAMeaningfulSubjectLine

NotACodeMill

KeepItDown

Thanks for your consideration. You will find they lead to a more productive exchange than non-negotiable demands do.

Oh, and by the way this is a Swing question, so let me move it over to the Swing forum...
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

mike molin wrote:Ok here is my problem.

I suspect you have bigger problems than this one though not technical.

Please don tell me to go look in API or some other guide on the internet that's just crap, if you know how to slove
this PLEASE POST THE CODE WITH EXPLANATION OTHERWISE DON'T BOTHER TO RESPOND

With this you have just about guaranteed that you will not get any help!

Best of luck.

Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

mike molin wrote:Please don tell me to go look in API or some other guide on the internet that's just crap, if you know how to slove
this PLEASE POST THE CODE WITH EXPLANATION OTHERWISE DON'T BOTHER TO RESPOND

I was about to point you to to the exact API location, but apparently you don't want to know it. Your loss. You forgot to BeNice.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
... but in the same JFrame as the menu,i don't want it to pop up a new JFrame ...


You should never "popup" another frame. If you did use this approach you would "popup" a JDialog. An application should only have a single frame.

Please don tell me to go look in API or some other guide on the internet that's just crap


Too bad because the Swing tutorial has a working example that shows you how to do this with an explanation. It makes no sense for me to repost the code and explanation here since it is a waste of my time since I won't be able to explain the code any better than the tutorial. Since you don't want links or you don't want to know what part of the API to read I guess you will have to find it on your own. Good luck.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3070
    
  33

mike molin wrote:
Please don tell me to go look in API or some other guide on the internet that's just crap, if you know how to slove
this PLEASE POST THE CODE WITH EXPLANATION OTHERWISE DON'T BOTHER TO RESPOND
thanks


API- This is the base for all the thousands of pages of books written. So it cannot be "crap". And main idea of JavaRanch is to help you solve the problem- If the problem is solved by you with the inputs from JavaRanch members then the next time you need not go scouting around for solutions.

If you had read the API- JPanel has something called- setVisible(Boolean) you could have used it to hide/show your JPanels.


Mohamed Sanaulla | My Blog
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

There is another, better solution for this. However, it can be found in the API and tutorial so I'm not allowed to link to it.

OK, I'll give a little hint. It's a layout manager. Note that I do not want anyone but Mike to name that layout manager. Let him find out that the API and tutorials are a useful tool indeed. And show us he can ShowSomeEffort and BeNice.
mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
ha i solved it
mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
JTabbedPane is the solution
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

JTabbedPane is a solution yes, if you want (or don't mind) the tabs themselves. But tell me, did you find that from the API or Java tutorials? Or did you google around?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
mike molin wrote:JTabbedPane is the solution


Based on your original requirement of using a frame with menus, it is not the appropriate solution, but it is a solution for a different requirement.
mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
well the JTabbedpane is like a menu, that was what i was meaning, not a menu like you scroll on the side with JMenubar.
so anyways it's the best sulotion for me.
Michael Salvini
Greenhorn

Joined: May 25, 2010
Posts: 20
...


Learning Java & Studying for the SCJA
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10372
    
    8

Michael,
I have edited out your post. You can start a new thread by clicking on the and post your question there.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Salvini
Greenhorn

Joined: May 25, 2010
Posts: 20
Sorry Maneesh. I had only posted here because the question was directly related to what was being discussed. Sorry about that. I will re-post my quesiton.

Thanks,
Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you switch JPanels to be shown within the same JFrame