Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Camick
Ranch Hand
Posts: 2564
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... 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
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ha i solved it
 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTabbedPane is the solution
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I have edited out your post. You can start a new thread by clicking on the and post your question there.

 
Michael Salvini
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic