• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I base all of my windows on JFrame?

 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . Go through the API and you will find that JWindow, JDialog and JFrame already inherit from Object in the same fashion.
 
Crusading Chameleon likes the size of this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic