• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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());
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!