Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2004

Tip: Looking for answers? Try searching our database.

JInternalFrame problem

Thread view: 
Jonathan Kapleau - 09 Jun 2004 18:08 GMT
I create a JInternalFrame and add it to the JDesktopPane

   JDesktopPane desktop = new JDesktopPane();
   ...
   desktop.add(new MyJInternalFrame());

but when I call "getDesktopPane()" from within the new JInternalFrame
the method returns null.  What am I doing wrong?
Fred L. Kleinschmidt - 10 Jun 2004 15:13 GMT
> I create a JInternalFrame and add it to the JDesktopPane
>
[quoted text clipped - 4 lines]
> but when I call "getDesktopPane()" from within the new JInternalFrame
> the method returns null.  What am I doing wrong?

And just how do you call getDesktopPane() from that new JInternalFrame?
You did not keep a reference to the MyInternalFrame added to desktop.
Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225

Jonathan Kapleau - 10 Jun 2004 20:02 GMT
> > I create a JInternalFrame and add it to the JDesktopPane
> >
[quoted text clipped - 7 lines]
> And just how do you call getDesktopPane() from that new JInternalFrame?
> You did not keep a reference to the MyInternalFrame added to desktop.

My bad.  I subclass the JInternalFrame and from within the code for
MyInternalFrame I call it as:

       this.getDesktopPane();

besides, can't I get refences to all the JInternalFrames from the
JDesktopPane?
Fred L. Kleinschmidt - 11 Jun 2004 15:26 GMT
> > > I create a JInternalFrame and add it to the JDesktopPane
> > >
[quoted text clipped - 12 lines]
>
>         this.getDesktopPane();

This will not work if you are calling getDesktopPane() from the
MyJInternalFrame constructor, since the MyJInternalFrame is not added to
the desktop until after the constructor finishes - the above is somewhat
equivalent of:

         MyJInternalFrame myframe = new MyJInternalFrame();
         desktop.add( myframe );
         myframe = null;

> besides, can't I get refences to all the JInternalFrames from the
> JDesktopPane?

Which object really needs to refer explicitly to the internal frame -
desktop, or the class in which the desktop resides? If you have multiple
JInternalFrames in the desktop, then, sure, you can use
desktop.getAllFrames() to retrieve them, but then you have to figure out
which of them to use for some specific operation. Why not just keep the
reference when you create the JInternalFrame?
Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225

Jonathan Kapleau - 12 Jun 2004 02:53 GMT
> > My bad.  I subclass the JInternalFrame and from within the code for
> > MyInternalFrame I call it as:
[quoted text clipped - 9 lines]
>           desktop.add( myframe );
>           myframe = null;

Thanks, this is something I had not considered.  Does this still apply
if the MyJInternaFrame constructor calls another method?  For example:

public MyJInternalFrame() {

   ...

   launch();
}

void launch() {

   ...

   getDesktopPane();
}

Thanks.
Lou Lipnickey - 11 Jun 2004 14:05 GMT
I had a similar problem with this awhile ago. Are you running this as an
applet or as an application (.java)? I was running as an application and
remember reading about a bug relative to the application. However, if
applet was extended (vs jframe), and incorporated other classes to
extend JFrame, the whole thing worked. - Lou

> I create a JInternalFrame and add it to the JDesktopPane
>
[quoted text clipped - 4 lines]
> but when I call "getDesktopPane()" from within the new JInternalFrame
> the method returns null.  What am I doing wrong?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.