Open the application multiple times in the same instance

Discussion in 'Java' started by nickkrause@dplg.com, Nov 12, 2005.

  1. Guest

    Hello,

    we are creating a swing application, using the following standard code:

    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }
    });

    Every time we call our program, it opens a new application. If we call
    it twice, 2 applications will be opened.
    We want to avoid that.
    That is, we call first our program, it opens the application once.
    Then everytime we call our program again, it opens it in the same
    previously opened application.

    Do you know how to do that?

    Thanks,
    Nick
     
    , Nov 12, 2005
    #1
    1. Advertising

  2. <> schreef in bericht
    news:...
    > Every time we call our program, it opens a new application. If we call
    > it twice, 2 applications will be opened.
    > We want to avoid that.
    > That is, we call first our program, it opens the application once.
    > Then everytime we call our program again, it opens it in the same
    > previously opened application.
    >
    > Do you know how to do that?


    There are several ways to do this. The basic idea is to register the presence
    of the application when it first starts up. Subsequent application calls can
    then check this presence. Because a new JVM might be created when a new
    application call is made, a JVM-local registration is not reliable. Instead
    you can consider to create a file at a known location or to open an IP port
    bound to localhost.
     
    Boudewijn Dijkstra, Nov 12, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    407
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 5, 2005
  2. David Hubbard
    Replies:
    2
    Views:
    848
    David Hubbard
    Jan 12, 2006
  3. Alan Foxmore
    Replies:
    2
    Views:
    353
    Alan Foxmore
    May 25, 2006
  4. Alessandro Crugnola *sephiroth*

    avoid multiple instance of the same application

    Alessandro Crugnola *sephiroth*, Nov 25, 2003, in forum: Python
    Replies:
    0
    Views:
    440
    Alessandro Crugnola *sephiroth*
    Nov 25, 2003
  5. Jack Steven
    Replies:
    2
    Views:
    454
    Chris Rebert
    Mar 9, 2009
Loading...

Share This Page