Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

How to fix a window i.e Frame

I have a Frame where there are 3 buttons.
When i click on Button 1, Frame1 get opened.
and similarly on other buttons.

How to lock Frame1 so that the user is not able to get into the other frames. As he may shift between windows.
or how to lock the current window or frame.
0
searchsanjaysharma
Asked:
searchsanjaysharma
  • 3
1 Solution
 
krakatoaCommented:
You'll probably have to implement an event listener, so when the frame gets the focus, you can neuter it.
0
 
CEHJCommented:
Generally speaking, there should only be one Frame/JFrame per application. Additional windows should usually be dialog types. If you make your additional windows extend JDialog instead, set them to modal, and they won't be able to open more than one at a time
http://docs.oracle.com/javase/6/docs/api/java/awt/Dialog.html#setModal(boolean)
0
 
krakatoaCommented:
What you can also consider is adding :

f.setFocusableWindowState(false);

Open in new window


where f is the JFrame instance of course.
0
 
searchsanjaysharmaAuthor Commented:
tx
0
 
krakatoaCommented:
Ok - not a great solution at all mine, as you know. And as CEHJ said, and I forgot to say, the best way is to use Dialogs for more modal flexibility. If it's not too late, you should consider that.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now