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