> i have an application in which after selecting an item from JMenuBar
> another window is opened.Again selecting the same option the window is
> opened once again.
> I want that once a particular window is opened another instance of same
> window should not open.
I'm new to Java but a few (possibly foolish) ideas occur to me:
1) Make the window modal (using JOptionPane instead of e.g. JFrame).
or
2) Keep track of window state (open, not) in a static boolean tested &
set in the constructor. Though this would need care to eliminate
possible race conditions.
or
3) instantiate the window when the app starts up, thenceforward just use
its setVisible(true) rather than instantiating it. use setVisible(false)
rather than closing it.
I've used option 1 but am interested in finding out what other ways
there are of structuring an application. What approach are you using?
Monique Y. Mudama - 24 Apr 2006 19:36 GMT
> or 3) instantiate the window when the app starts up, thenceforward
> just use its setVisible(true) rather than instantiating it. use
> setVisible(false) rather than closing it.
You could also instantiate the window the first time a user tries to
open it; thereafter just do setVisible() ...

Signature
monique
Help us help you:
http://www.catb.org/~esr/faqs/smart-questions.html