Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get jframe instance from a jpanel

918178Sep 11 2012 — edited Sep 12 2012
Hi,

I am working on a Java swing framework in my project. I am extending a project customized panel. For one of my requirement I need to get the frame in which the panel is fixed.

The customized project panel extends JPanel class.

My need is, is there any way get the instance of the frame from the panel.

I tried , JFrame f = (JFrame) panel.getParent() and JFrame f = (JFrame) SwingUtilities.getRoot(panel); but they return only null value.

Please help me on this..

REgards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 10 2012
Added on Sep 11 2012
9 comments
7,365 views