Results 1 to 7 of 7
- 06-04-2010, 06:21 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
java message box, how to not show multiple message box with same title or content
hello,
how can i prevent another message box of the same content or title from displaying again if user haven't closed the existing message box?
for example, program runs, then display a message box, program end, user don't close message box.
program runs again, display same message box again <-- how to prevent this if message box is still displayed?
thanks.
- 06-04-2010, 06:29 PM #2
Is this problem with a program you are writing or is it someone else's program?
Usually when a program ends, all its stuff goes away. If there is a message box still displayed, then the program is probably still running.
Can you explain a bit more?
- 06-04-2010, 06:53 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
it's from a sample. it's a google desktop widget (which are js stuff) but the java part is doing some file operation, which is called by a js file, simply do a shell.Run(mycmd) where mycmd="java -jar somejar.jar somefile opt1 opt2 opt3 etc..." so the java process runs and just exit, the message box is still displayed.
here is a snippet from the class displaying the message box:
public AlertWindow(String errMsg, final int closeInterval, final String callback){
myFrame.setLocationRelativeTo(null);
myFrame.getContentPane().setLayout(new BorderLayout());
myFrame.setBackground(Color.white);
JTextArea label = new JTextArea(errMsg);
label.setEditable(false);
label.setWrapStyleWord(true);
label.setBackground(Color.white);
label.setBorder(null);
JButton ok = new JButton("OK");
ok.setMnemonic('o');
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
if(callback!=null){
String surl = "https://www.someurl";
try{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+ surl);
}catch(Exception ee){}
}
System.exit(0);
}
});
label.setBounds(10, 5, 360, 50);
ok.setBounds(170, 60, 55, 25);
myFrame.getContentPane().setLayout(null);
myFrame.getContentPane().setBackground(Color.white );
myFrame.getContentPane().add(label);
myFrame.getContentPane().add(ok);
myFrame.setSize(400,130);
myFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
- 06-04-2010, 07:12 PM #4
Must be starting a program that is independent of the java program.Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+ surl);
What is the value of surl?
- 06-04-2010, 07:17 PM #5
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Yes, starting a program that is independent of the java program.
[...]
String surl = "https://www.someurl";
try{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+ surl);
}catch(Exception ee){}
}
[...]
- 06-04-2010, 07:20 PM #6
You're asking if the java program can detect if another program is running.how to prevent this if message box is still displayed
I don't know of any way in java. You'd have to use JNI to talk to some native code that could find out.
- 06-04-2010, 08:43 PM #7
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
short message service (SMS in java)
By ashin in forum Advanced JavaReplies: 4Last Post: 06-04-2011, 07:59 AM -
Java Private Message System
By javaNumpsy in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-29-2010, 05:11 PM -
Java Message Server/Client help
By sari in forum NetworkingReplies: 3Last Post: 03-20-2010, 11:17 PM -
Java Message Service
By Java Tutorial in forum Java TutorialReplies: 0Last Post: 06-09-2008, 09:57 PM -
java error message
By baileyr in forum New To JavaReplies: 2Last Post: 01-23-2008, 03:47 AM


LinkBack URL
About LinkBacks

Bookmarks