This week's book giveaway is in the Testing forum.
We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!
See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make sure JDialog will always be in front (with 2 or more JDialogs)

Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

* H.E.L.P *

Dialog, in most cases, requires the user to address a specific issue (YES/NO, CONFIRM, etc). They also block the user from doing anything else but addressing the dialog FIRST (you cannot click the menu item before you �got rid of� the dialog).

This is simply great as I can build my own dialogs and make sure that the user can access only one �record� at a time (a record is just a collection of information on a dialog with 2 buttons: EXIT and UPDATE).

This is working just great, my users are searching for information and by double clicking the info they want they can access the record (if they change something they can update it and exit).

Well, after 5 months I realized that I had a critical mistake: if the user double clicks on a record and the record is open (now there are 2 frames: the main frame and the dialog) AND the user, for some reason, switches to a different application (say: MS outlook) and returns to the Java application � the dialog (record) is BEHIND the main frame. That means that the user CANNOT do anything (most of them reset the computer). ALSO, from the �record� they can open a new window (again dialog) and this cannot be accessed.

Any idea how to make sure the dialog will always be at the front?

This is my code:
if (e.getClickCount() == 2)
JFrame tmp = new JFrame();
JDialog editor=new JDialog(tmp,"Editor",true);
Record tmpRec = (Record) model.getElementAt(aTable.getSelectedRow());
DirectEdit direct = new DirectEdit(editor, tmpRec.getKEY());
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic