swing使用动作侦听器隐藏和显示java桌面应用程序
我有一个用netbeans编写的java桌面应用程序。 我所做的就是听到窗口关闭并最小化托盘。 我添加到我的应用程序。java是一种启动时侦听器方法,它侦听窗口关闭,然后隐藏myAppView
我在任务栏中创建了一个icontray,我想打开和以前相同的框架。 我将appView声明为全局变量,但可以执行show(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);
}
共 (0) 个答案