SWT能不能动态改变Shell的Style
解决方案 »
- java消除闪烁
- 关于static
- Java核心编程的例题,为什么总报数组下表溢出
- 表达能力比较差啊,回复了将近200个帖子啊。没有一个人明白我的意思的啊。我重新又整理了一下,同时感谢大家前面的参与啊。真心谢谢大家啊!
- 谁能帮忙说一下API文档的具体查找方法
- java 连接 数据库access 错误,高手请止步~~~~~~~~
- 关于事件的问题,dyroro(丢丢) 请进!
- 各位用JAVA做Web-based Application的朋友,有没有这种感觉?
- 入门者问 怎么把我写的类打成一个package???
- 如何用qq或者新浪微博进行登录一些app网站
- java socket 服务端怎么写两个serverSocket?
- 为什么运行后不显示标签文本?不闪烁?
需要换style的时候,把这个composite按需要的style重新new一下
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();
}
}
这个看似可以,但子Shell并不在父Shell后面,只是可以操作父Shell