Java SWT????????????
???????????? ???????[ 2013/8/8 15:00:52 ] ????????
//????????
shell.addShellListener(new ShellAdapter() {
//??????С?????????????????????????
public void shellIconified(ShellEvent e) {
toggleDisplay(shell?? tray);
}
//???????????????????????????????????????????
public void shellClosed(ShellEvent e) {
e.doit = false; //?????????
toggleDisplay(shell?? tray);
}
});
shell.setSize(320?? 240);
center(shell);
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
/**
* ????????????????????????????????????
* ?????????????????????????????????
*/
private static void toggleDisplay(Shell shell?? Tray tray) {
try {
shell.setVisible(!shell.isVisible()); //?????????
tray.getItem(0).setVisible(!shell.isVisible()); //???????????
//?????????????
if(shell.getVisible()) {
shell.setMinimized(false); //???????С??
shell.setActive(); //??????
}
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* ?????????
*/
private static void center(Shell shell) {
Monitor monitor = shell.getMonitor();
Rectangle bounds = monitor.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + (bounds.width - rect.width)/2;
int y = bounds.y + (bounds.height - rect.height)/2;
shell.setLocation(x?? y);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11