Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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
0
jespersahner
Asked:
jespersahner
  • 5
  • 3
  • 3
1 Solution
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now