Solved

How to fix a window i.e Frame

Posted on 2013-06-20
5
316 Views
Last Modified: 2013-06-21
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
Comment
Question by:searchsanjaysharma
  • 3
5 Comments
 
LVL 16

Expert Comment

by:krakatoa
ID: 39261869
You'll probably have to implement an event listener, so when the frame gets the focus, you can neuter it.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39261919
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
 
LVL 16

Accepted Solution

by:
krakatoa earned 500 total points
ID: 39262244
What you can also consider is adding :

f.setFocusableWindowState(false);

Open in new window


where f is the JFrame instance of course.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39265059
tx
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 39265270
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 62
IT Company 5 69
Eclipse Neon and jdk 1.8.0 11 66
Unable to start eclipse ? 17 83
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now