• Post Reply Bookmark Topic Watch Topic
  • New Topic

Gaining Focus  RSS feed

 
Ziyod Abdullayev
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's up folks
I have a JFrame#1 and im trying to invoke from JMenuItem another JFrame#2 but until #2 Frame closes i don't wanna user to have focus on #1 Frame.
Any suggetions.
I tried addNotify but it doesn't work since #1 or #2 don't extends neither of each.
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
why do u use another frame,u can use Dialog,
and make that dialog as a modal one.it will
help u,not obtain focus on the Frame,until u close the modal dialog.
Raj
 
Ziyod Abdullayev
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj i thought about changing to JDialog but i already have everything for my frame.
Thanks anyway
Ziyod
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to use a JDialog if you want the second frame to be modal to the first... besides, to change from a JFrame to a JDialog is extremely trivial... most code will work fine if you just change the 'extends JFrame' to 'extends JDialog', change the constructors to match the JDialog constructors you are insterested in, and change where the second frame is being created to call one of those constructors.

-Nate
 
Ziyod Abdullayev
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution all i did is I passed reference of #1 frame and setEditable(false) for it and when #2 closes i just catch windowClosing and setEditable(true).
Thanks for everybody who replied
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!