• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ha i solved it
 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTabbedPane is the solution
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic