Dialog Box should pop up no matter what - like an alert-box

Hi!

I am using a simple dialog box in the following way:
JFrame jframe=new JFrame("News");
JOptionPane.showMessageDialog(jframe,"Hi there!");                                

This pops up when the application (or another program) is in focus.

However if
1) all windows are minimized
or
2) I am actively working in another window (e.g. moving a scroll-bar in another window continuously)
- the window doesn't make an interrupt.

I would like the dialog box to make an interrupt no matter what - like an alert-box.

How is that done?

Regards,
Jesper
jespersahnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
you'll need to use native code to achieve that I think
0
Mayank SAssociate Director - Product EngineeringCommented:
I guess so. This might be tough even in C#
0
jespersahnerAuthor Commented:
Ok, but what is a dialog box worth, if it doesn't always pop up? What surprises me is, that it pops up, when another window is in focus and I am not working in that window so to speak. However if I am working in the window (moving a scrollbar or something) the dialog box doesn't pop up. And when all windows are minimized the dialog box doesn't show either.

Are there any other possibilities like making a blinking icon on the Windows status-bar? (guess this also needs to use native code). Would it be easy to send a message in DOS?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Mayank SAssociate Director - Product EngineeringCommented:
>> Would it be easy to send a message in DOS?

Maybe you can try "net send" and do a Runtime.exec () on it :)
0
jespersahnerAuthor Commented:
->mayankeagle: I am running XP SP2, so "net send" is disabled.
0
objectsCommented:
it pops up relative to your java app, dialog are only modal to the application, not the OS.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jespersahnerAuthor Commented:
Actually I think I am not telling you the whole truth.

I experience the following: To test it out I make a pop-up every 10 second. If I let the application stay in focus until the first pop-up is shown, it is always able to get focus later, even if the application is not in focus. On the other hand if I start up the aplication and don't wait for the first pop-up, pop-ups will never get focus. I don't quite understand this, but I think my problem is solved, if I just wait for the first pop-up to show.

Regards,
Jesper

0
jespersahnerAuthor Commented:
If you are able to explain this to me, you are welcome to throw an answer ;-)
0
objectsCommented:
not sure i follow, can u post an example I could run that demonstartaes it
0
Mayank SAssociate Director - Product EngineeringCommented:
Sounds like a bug in XP ;-D
0
jespersahnerAuthor Commented:
->objects: Consider the following simple example:

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ShowMessage {    
    public static void main(String[] args) throws InterruptedException {
        for (int i=0;i<3;i++) {
            Thread.sleep(5000);
            JOptionPane.showMessageDialog(new JFrame(),"Message "+i,"MessageDialog",JOptionPane.INFORMATION_MESSAGE);
        }        
        System.exit(0);
    }    
}

Now try the following:
1. Run the program
2. Switch to another window (IE, Word, whatever) before the first message is shown
3. The program is not able to gain focus (however the first message can be found using Alt+Tab)

Instead now try:
1. Run the program and wait for the first message to show
2. Switch to another window
3. The program now is able to gain focus

Regards,
Jesper
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

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.