62,634
社区成员




import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ShellTest implements SelectionListener {
private Display display;
private Shell shell;
private Button button;
private boolean flag = false;
public ShellTest() {
display = new Display();
shell = new Shell(display);
shell.setLayout(new RowLayout());
build();
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
private void build() {
button = new Button(shell, SWT.PUSH);
button.setText("Push ME");
button.addSelectionListener(this);
}
public void widgetSelected(SelectionEvent evnt) {
if (flag == true) {
shell.dispose();
flag = false;
shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new RowLayout());
build();
shell.open();
} else {
shell.dispose();
flag = true;
shell = new Shell(display, SWT.NO_TRIM);
shell.setLayout(new RowLayout());
build();
shell.open();
}
}
public void widgetDefaultSelected(SelectionEvent evnt) {
}
public static void main(String[] args) {
new ShellTest();
}
}
child = new Shell(parent);
创建一个子窗口后,焦点是在子窗口的,只要你的子窗口不是模态貌似点击父窗口就可以让父窗口在子窗口前面了,你试试看看