• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multiple windows open

 
sandy yang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
myMenu.setEnabled(false) or myMenuItem.setEnabled(false) then set them to true when the window is closed.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could make your other windows dialogs and make them modal.
 
sandy yang
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic