我在swt中新建一个Label的时候,想让它显示在原来的一个Label的上面,但是动态新建之后,它的层次总是在原来的Label下面(被原来的Label覆盖),该如何设置Label的层次(深度)?
解决方案 »
- 请问怎样用java(JAI)提取TIFF中的一个通道并保存?
- 问一个字符串分割的方法,不知道哪位有好办法呀
- 如何高亮表格的某一行(不点击鼠标哦)
- return问题!!
- 我翻译的部分《Java 编码规范》,感兴趣的可以看看,你们的鼓励使我继续的动力。
- 搞脑子的笔试题,想挑战的来吧(2)
- 多行文字TextArea的问题
- 请教各位: JVM在不同的平台上是否有区别?(即是否分JVM for x86, for SPARC, etc.)?
- 一个JAVASCRIPT调用APPLET方法的问题!!!(在线等待...)
- 本地运行网页中嵌入的Java applet
- The import javax.media cannot be resolved 请问如何解决?
- 如何画虚线的圆?
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Composite parent = new Composite(shell, SWT.NONE);
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
final StackLayout layout = new StackLayout();
parent.setLayout(layout);
final Label oldLabel = new Label(parent, SWT.NONE);
oldLabel.setText("Old Label");
final Label newLabel = new Label(parent, SWT.NONE);
newLabel.setText("New Label");
layout.topControl = newLabel;
Button b = new Button(shell, SWT.PUSH);
b.setText("Show Label");
b.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent arg0) {
if(layout.topControl == newLabel){
layout.topControl = oldLabel;
}else{
layout.topControl = newLabel;
}
parent.layout();
}
});
shell.open();
while (shell != null && !shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}