Results 1 to 7 of 7
  1. #1
    oohay is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

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

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    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?

  3. #3
    oohay is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default

    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);
    }
    });

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+ surl);
    Must be starting a program that is independent of the java program.

    What is the value of surl?

  5. #5
    oohay is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default

    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){}
    }
    [...]

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    how to prevent this if message box is still displayed
    You're asking if the java program can detect if another program is running.
    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.

  7. #7
    oohay is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. short message service (SMS in java)
    By ashin in forum Advanced Java
    Replies: 4
    Last Post: 06-04-2011, 07:59 AM
  2. Java Private Message System
    By javaNumpsy in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-29-2010, 05:11 PM
  3. Java Message Server/Client help
    By sari in forum Networking
    Replies: 3
    Last Post: 03-20-2010, 11:17 PM
  4. Java Message Service
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 06-09-2008, 09:57 PM
  5. java error message
    By baileyr in forum New To Java
    Replies: 2
    Last Post: 01-23-2008, 03:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •