JDialog always on top

Posted on 2002-05-28
Last Modified: 2011-04-14
how can I make my dialog (derived from JDialog) to be always on the top ?
What I want to do - I have an GUI App (programmed using Java Swing). In an separate thread I start a time consuming job. Now I would like to show something like modal dialog which shows the progress. So the main application window cannot be accessed until the thread stops or a button is pressed in the progress window. How can it be done ?

Thanx a lot.
Question by:izi13
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 92

Expert Comment

ID: 7038852
Just make your GUI's frame the dialog parent (passed to the ctor).
A JDialog will always stay on top of it's parent frame.
LVL 35

Accepted Solution

girionis earned 100 total points
ID: 7038865
 ...And another possible solution can be found here:

  Hope it helps.
LVL 16

Expert Comment

ID: 7038867
public JDialog(Frame owner, boolean modal)
Creates a modal or non-modal dialog without a title and with the specified owner frame.
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.


Expert Comment

ID: 7039543
There is two types of Dialog boxes.

Modal and non-modal. A modal is  your required type.
Please the check the following Constructors:-

JDailog(Frame parent,true);
This will create a Modal(all ways on top) Dialog box.

LVL 35

Expert Comment

ID: 7039593

1) Please do not propose answers as this locks the question to other experts and it is more difficult to answer. Post comments instead as comment can still be accepted as answers.

2) Your answer is exactly what heyhey said.
LVL 92

Expert Comment

ID: 7040536
And what I said, and also incorrect as a nonmodal dialog will also stay on top.

Author Comment

ID: 7041175
The most appropriate answer for me is the comment fom girionis, because I create/show the dialog in my main frame's processEvent method and I don't want it to be blocked by the dialog.
Thanx to all anyway ...
LVL 92

Expert Comment

ID: 7041197
I don't understand what you mean, but as long as your happy :-)
LVL 35

Expert Comment

ID: 7041201
 izi13 thanks for the points. I am glad I've helped :-)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 85
check java version using powershell 13 442
going to wrong jsp page 2 68
program arguments vs VM arguments 4 55
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

739 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