简体   繁体   中英

Make a jframe appear only at the first start

I have a program and I need to show a windows only at the first start of the application. What I should do? I make two classes or two JFrames in one class?

I think your goal is a multiple document interface .

  • If the application is started a JFrame is opened with a new "document".
  • If the application is started a second time the first JFrame appears instead.

Other scenarios:

  • If a document is opened in the operating system, the application starts with that document (JDesktopWindow?) in a JFrame.
  • If a second document is opened in the operating system, the first application opens the second document (in a new JDesktopWindow) in the same JFrame.

To implement this behaviour I used java RMI (remote method invocation).

  • The application when running the first time listens on its chosen port as server.
  • On start it tries as client to find a server (older instance of the application). If found it passes its command line arguments to an open call, and then quits.
  • (Otherwise it starts the server and opens.)
import javax.swing.*;
   public class aaaaa {

   public static void main(String[] args) {
      new JFrame().setVisible(true);
   }

}

at the first you mean like this??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM