Forums Register Login

Can I base all of my windows on JFrame?

+Pie Number of slices to send: Send
I'm used to a class library (pre-Java, but object-oriented), that based all windows on a single base class. If written in Java, it would be like the following:



Is the above design possible in Swing, using the JFrame class? I'd like everything, deep-down to have a common anscestor class like JFrame. I'd rather do this than use three different classes:

JFrame for modeless windows.
JDialog for modal windows.
and
JOptionPane for simple alerts.

Is my design a good use of Swing or am I "going against the grain."

Kaydell
[ May 27, 2007: Message edited by: Kaydell Leavitt ]
+Pie Number of slices to send: Send
All of these classes already have java.awt.Component as an ancestor; maybe you can make use of that fact.

But as far as top level windows go, I don't think there's any reason you're forced to use JDialog or JOptionPane, except for modality; off the top of my head I don't believe you can implement a true modal dialog with JFrame (someone may prove me wrong here, though.) If you can live without true modal dialogs, then there's no reason not to do what you suggest, other than the reinventing-the-wheel that' you'd be doing instead of using JOptionPane.
+Pie Number of slices to send: Send
. . . Go through the API and you will find that JWindow, JDialog and JFrame already inherit from Object in the same fashion.
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 930 times.
Similar Threads
update the JVM from 1.5 to 1.6, JDialog (modeless) background cant paint
how to program base class as singletone that other class's when extend it will become singletone
SWING Multiple GUI
Design suggestions for new app
Close Dialog Box(Urgent!)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:23:27.