`
daxiaoli123
  • 浏览: 45470 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
社区版块
存档分类
最新评论

swt

 
阅读更多
public class SWTDemo {
StackLayout stackLayout = new StackLayout();
private Display display = new Display();
Shell shell = new Shell(display);
Composite yourDataComp;
Composite parentComp;
public SWTDemo() {
init();
}

private void init() {
shell.setText("swt demo");
shell.open();
getSashForm();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
     public void getSashForm() {
SashForm sashForm = new SashForm(shell, SWT.VERTICAL);

Composite upComposite=new Composite(sashForm, SWT.BORDER);
upComposite.setBackgroundImage(new Image(shell.getDisplay(),"./icons/swtup.png"));

SashForm leftSashForm = new SashForm(sashForm, SWT.HORIZONTAL);
Composite downComposite=new Composite(sashForm,SWT.BORDER);
Button runButton=new Button(downComposite,SWT.None);
runButton.setText("Run");
runButton.setBounds(740, 20, 88, 26);

Button buttonClose=new Button(downComposite,SWT.None);
buttonClose.setText("close");
buttonClose.setBounds(830, 20, 88, 26);

sashForm.setWeights(new int[] { 1, 8,1}); //分成上一份 中 八分  下 一份
Composite composite = new Composite(leftSashForm, SWT.NONE);
Tree tree = LeftComposite.getScomposite(composite);
Composite rightComposite = new Composite(leftSashForm, SWT.BORDER);//右面板
rightComposite.setLayout(stackLayout);
sashForm.setLayout(stackLayout);
        //共两页。将生成此面板的代码提出成一个方法,保证代码结构的清晰。
        yourDataComp = createYourDataComp(rightComposite);//个人资料的面板
        parentComp = createOtherComp(rightComposite);//eclipse 详细资料
        //在堆栈面板上先显示“个人资料”界面
        stackLayout.topControl = yourDataComp;
tree.addSelectionListener(new TreeSelect(tree, rightComposite,this));
leftSashForm.setWeights(new int[] { 1, 3 });
sashForm.setBounds(5, 5, 940, 630);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics