Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to toggle differenet jpanel in jframe  RSS feed

 
Rajesh Tarte
Ranch Hand
Posts: 33
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am working on one application
and have jframe including some jpanels
i have some other jpanel classes and want to replace one jpanel in jframe with the other japnel class
i am able to remove the current jpanel and also able to add other jpanel in same class but unable to add jpanel written in other class
can anybody figure out what the problem is?
i also used validate() and repaint() methods

Krishna
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Instead of adding and removing panels I'd look into using a CardLayout instead, which lets you switch between any number of panels dynamically.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> i also used validate() and repaint() methods

swing components use revalidate() and repaint()

but far easier to add all you panels to a CardLayout panel, then show the one you want

http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html

 
Rajesh Tarte
Ranch Hand
Posts: 33
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for quick response
will check it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!