File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes multiple windows open Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "multiple windows open" Watch "multiple windows open" New topic
Author

multiple windows open

sandy yang
Greenhorn

Joined: Jan 26, 2001
Posts: 8
my main window has several menus(File, Edit, View, Help, etc). every menu has serveral menuitems(under Help menu, there is Help Topics, AboutBox). each muneItem can open a new window. The problem is the user can open as many windows as he wants without close the current one. What do i need to do to disable all the menus if there is window opens?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

myMenu.setEnabled(false) or myMenuItem.setEnabled(false) then set them to true when the window is closed.


GenRocket - A Test Data Generation Platform
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Or you could make your other windows dialogs and make them modal.
sandy yang
Greenhorn

Joined: Jan 26, 2001
Posts: 8
Thanks Gregg and Paul. All my windows are extend JFrame. I can't just simply enable/disable the menu. When the user runs the application, a main window opens. then he clicks a menuitem on the main window, the second windows opens in front of the main window. the user suppose can't do anything without close the second window. anywhere he clicks outside the second window, the second window should get focus and remind the user close the second window.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Well, if you are doing it that way, I would suggest using a JDialog instead of JFrame for your other windows outide of the main app. That way, they will have to close that new window before they could even do anything on the main app.
However, I don't understand why you can't disable the menu items.
Just because you are spawning a new JFrame doesn't mean you can't disable the Menu in the main Frame of your App. Unless you are using the same CLASS to create each new Window and each window contains the same menu bar. If that is the case, I say that is poor design.
 
Don't get me started about those stupid light bulbs.
 
subject: multiple windows open
 
Similar Threads
Target tag - new browser without menus?
setHelpMenu method of MenuBar
Menu Problem
Check the JFrame is opened already or not
Help JMenu is getting frozen and won't go away