Results 1 to 3 of 3
- 04-13-2012, 10:50 AM #1
Senior Member
- Join Date
- Oct 2011
- Posts
- 106
- Rep Power
- 0
Set visibility of parent Container
I have been searching the documentation. What I am trying to do is change the visibility of the parent (JPanel) in this case, on button click. I tried getting the container and then casting to a JComponent but that didn't work. How do I get a hold of the current instance of the parent?
Thanks
- 04-13-2012, 12:07 PM #2
Re: Set visibility of parent Container
Moved from New to Java.
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-14-2012, 02:37 AM #3
Re: Set visibility of parent Container
Casting should work if the button's parent is actually a JPanel. But you don't need to cast it at all to change its visibility. JButton.getParent() returns a Container, and Container extends Component, which means it has the setVisible(...) method.
Get in the habit of using standard Java naming conventions!
Similar Threads
-
Help! set dinamically visibility of panels
By unkus_nob in forum JavaFXReplies: 5Last Post: 06-21-2011, 09:06 PM -
Help with adding a Container within a Container
By JoKeR313 in forum New To JavaReplies: 4Last Post: 01-02-2011, 04:59 AM -
Java Visibility
By efozdel in forum New To JavaReplies: 8Last Post: 07-07-2010, 03:36 AM -
[SOLVED] Coordinates container --> in parent container.
By Cleite in forum AWT / SwingReplies: 3Last Post: 04-21-2009, 11:01 PM -
Newbie help on visibility and static final
By tornado in forum New To JavaReplies: 3Last Post: 11-28-2008, 01:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks