abhishekroy
asked on
How to get JInternalFrame form its contentPane??
Hi,
I have a JInternalFrame in my application and am adding a toolbar and JPanel to its contentPane.
I want to get to the JInternalFrame from the JPanel added to the contentPane. I am using getParent() and am able to get to the contentPane successfully but I'm not able to get to the JInternalFrame.
Any help would be appreciated.Thanks in advance.
Abhishek.
I have a JInternalFrame in my application and am adding a toolbar and JPanel to its contentPane.
I want to get to the JInternalFrame from the JPanel added to the contentPane. I am using getParent() and am able to get to the contentPane successfully but I'm not able to get to the JInternalFrame.
Any help would be appreciated.Thanks in advance.
Abhishek.
ASKER
Nopes! Doesn't work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Tip: the same algorithm is used for detection of top most Frame when you'll create a modal Dialog or JDialog.
ASKER
Thanks that works!
you're welcome
ASKER
Hey!
The above code works but not for my case.
I have a class WANView which extends JInternalFrame.
I am using the following code for accessing the JInternalFrame
Container parent = WANPanel.this;
/* WANPanel extends JPanel
* An instance of WANPanel is added to the WANView Frame's
* contentPane.
*/
while(!(parent instanceof WANView) && parent != null)
parent = parent.getParent();
WANView parentFrame = (WANView) parent;
parentFrame.toggleEditMode (false);
It's not working and throws exceptions.
What's the mistake I am making?
Please help.
The above code works but not for my case.
I have a class WANView which extends JInternalFrame.
I am using the following code for accessing the JInternalFrame
Container parent = WANPanel.this;
/* WANPanel extends JPanel
* An instance of WANPanel is added to the WANView Frame's
* contentPane.
*/
while(!(parent instanceof WANView) && parent != null)
parent = parent.getParent();
WANView parentFrame = (WANView) parent;
parentFrame.toggleEditMode
It's not working and throws exceptions.
What's the mistake I am making?
Please help.
panel.getParent().getParen
but there has to be a better way :-)