• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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