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 / April 2006

Tip: Looking for answers? Try searching our database.

Another instance of same window.

Thread view: 
kalpesh - 24 Apr 2006 13:44 GMT
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.
Ian Wilson - 24 Apr 2006 17:04 GMT
> 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



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.