2

我有一个用 netbeans 编写的 java 桌面应用程序。我所做的是听窗户关闭并最小化到托盘。我在 myApp.java 中添加了一个启动方法的监听器,它监听窗口关闭然后隐藏 myAppView。

我在任务栏中创建了一个图标托盘,我想打开以前的同一个框架。我将 appView 声明为全局变量,但可以显示(myapp),因为它说它是静态的。知道如何让它工作吗?

public class myApp extends SingleFrameApplication {
    private myAppView mainv;


    @Override protected void startup() {
        mainv=new myAppView(this);
        show(mainv);
        addExitListener(new ExitListener() {

           public boolean canExit( EventObject event ) {
              systray();
              hide(mainv);

              return false;
           }

        public void willExit( EventObject arg0 ) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
}

/**
 * This method is to initialize the specified window by injecting resources.
 * Windows shown in our application come fully initialized from the GUI
 * builder, so this additional configuration is not needed.
 */
@Override protected void configureWindow(java.awt.Window root) {

}

/**
 * A convenient static getter for the application instance.
 * @return the instance of find4me
 */
public static myApp getApplication() {
    return Application.getInstance(myApp.class);
}

/**
 * Main method launching the application.
 */
public static void main(String[] args) {
    launch(myApp.class, args);
}
4

0 回答 0