display = new Display();
mainShell = new Shell(display,SWT.SHELL_TRIM);
mainShell.setText("OnTopProblem");
mainShell.setLayout(new FillLayout());
Button btnClose = new Button(mainShell,SWT.PUSH);
btnClose.setText("Close");
btnClose.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event arg0) {
mainShell.dispose();
}
});
mainShell.setSize(300,200);
mainShell.open();
onTopShell = new Shell(mainShell,SWT.ON_TOP);
onTopShell.setSize(200,30);
onTopShell.open();
onTopShell.setLayout(new FillLayout());
labelIter = new Label(onTopShell,SWT.NULL);
Tray tray = display.getSystemTray();
TrayItem trayItem = new TrayItem(tray,SWT.NULL);
trayItem.addListener(SWT.DefaultSelection, new Listener() {
public void handleEvent(Event e) {
mainShell.setVisible(true);
}
});
mainShell.addListener(SWT.Close, new Listener(){
public void handleEvent(Event e) {
e.doit = false;
mainShell.setVisible(false);
onTopShell.setVisible(true);
}
});
Thread t = new AEThread("OnTopProblem") {
public void runSupport() {
while(updateDisplay()) {
try { Thread.sleep(100); } catch(Exception ignore) {}
}
}
};
t.start();
waitForDispose();
display.dispose();