Java swing application, close one window and open another when button is clicked

前端 未结 7 1940
离开以前
离开以前 2020-12-03 07:56

I have a netbeans Java application that should display a JFrame (class StartUpWindow extends JFrame) with some options when the application is launched, then the user clicks

7条回答
  •  暖寄归人
    2020-12-03 08:45

            final File open = new File("PicDic.exe");
            if (open.exists() == true) {
                if (Desktop.isDesktopSupported()) {
                    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    
                        public void run() {
                            try {
                                Desktop.getDesktop().open(open);
                            } catch (IOException ex) {
                                return;
                            }
                        }
                    });
    
                    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    
                        public void run() {
                            //DocumentEditorView.this.getFrame().dispose();
                            System.exit(0);
                        }
    
                    });
                } else {
                    JOptionPane.showMessageDialog(this.getFrame(), "Desktop is not support to open editor\n You should try manualy");
                }
            } else {
                JOptionPane.showMessageDialog(this.getFrame(), "PicDic.exe is not found");
            }
    

    //you can start another apps by using it and can slit your whole project in many apps. it will work lot

提交回复
热议问题