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 / August 2003

Tip: Looking for answers? Try searching our database.

App that is parented by either JFrame or JInternalFrame - strategies?

Thread view: 
Frank D. Greco - 24 Aug 2003 15:45 GMT
I have to create an app that can be parented by either a JFrame (ie, floating
on the desktop) or a JInternalFrame (ie, inside of an desktop environment).

Are there well-known patterns/models for doing this type of stuff?

My initial strategy is to create an interface providing common entry points and
the app deal with this interface as its 'parent'.

interface Parent {
    ...
}

class AppFrame extends JFrame implements Parent {
    ...
}

class AppIFrame extends JInternalFrame implements Parent {
    ...
}

class MyGUI {
    Parent p;
    App ap;

    void setParent(Parent np) {   // reparent to switch
        p = np;
    }
    ...
}

The downside to this strategy: the Parent is fairly large.  
It has to have to all the functionality that my app needs from a
JFrame or JInternalFrame (size, location, visibility, stacking-order,
et al).  Of course, its not good to have large interfaces as well all know.

Any good GUI architects out there have a more elegant mechanism?

Thanks,

Frank G.
+=========================================+
| Crossroads Technologies Inc.            |
| Enterprise Java Engineering             |
|   Web: www.CrossroadsTech dot com       |
| Email: fgreco @ crossroadstech dot com  |
+=========================================+
Jeremy - 25 Aug 2003 01:12 GMT
>can be parented by either a JFrame (ie, floating
> on the desktop) or a JInternalFrame (ie, inside of an desktop environment).

Sound like any other class you know of? :-)  Why not simply subclass JPanel
and put your entire application in there?  Then, whatever the parent, be it
JFrame, JInternalFrame, or even JApplet, you can call
parent.setContentPane(myApp); and presto, you've got your app.  Is this not
what you had in mind?

-Jeremy


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.