- import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.SWT; - public class ShellStyle {
- /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Display display = new Display();
Shell topShell = new Shell(display);
topShell.setText("窗口样式");
topShell.setSize(500, 400);
topShell.open();
Shell style1 = new Shell(display, SWT.TITLE);
style1.setText("只显示标题");
style1.setSize(50, 40);
style1.open();
Shell style2 = new Shell(display, SWT.CLOSE);
style2.setText("只显示关闭");
style2.setSize(50, 40);
style2.open();
Shell style3 = new Shell(display, SWT.MIN);
style3.setText("只显示最小化");
style3.setSize(100, 40);
style3.open();
Shell style4 = new Shell(display, SWT.MAX);
style4.setText("只显示最大化");
style4.setSize(100, 40);
style4.open();
Shell style5 = new Shell(display, SWT.BORDER);
style5.setText("显示边框");
style5.setSize(50, 40);
style5.open();
Shell style6 = new Shell(display, SWT.RESIZE);
style6.setText("大小可变");
style6.setSize(50, 40);
style6.open();
Shell style7 = new Shell(display, SWT.NO_TRIM);
style7.setText("无边框也无标题");
style7.setSize(50, 40);
style7.open();
Shell style8 = new Shell(display, SWT.SHELL_TRIM);
style8.setText("完整显示");
style8.setSize(50, 40);
style8.open();
Shell style9 = new Shell(display, SWT.DIALOG_TRIM);;
style9.setText("对话框");
style9.setSize(50, 40);
style9.open();
//还可以使用如下的:SWT.APPLICATION_MODAL, SWT.MODELESS,SWT.PRIMARY_MODAL
//SWT.SYSTEM_MODAL 与其它的组合使用 以 | 分割符
Shell style10 = new Shell(display, SWT.CLOSE | SWT.RESIZE);
style10.setText("多个样式");
style10.setSize(50, 40);
style10.open();
while (!topShell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
} - }
SWT之三:ShellStyle
最新推荐文章于 2016-10-14 13:22:00 发布