public class Demo2 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("分割窗口,拖动窗口边框可以改变窗口大小"); shell.setLayout(new FillLayout()); SashForm form = new SashForm(shell, SWT.HORIZONTAL | SWT.BORDER); form.setLayout(new FillLayout()); Composite child1 = new Composite(form, SWT.NONE); child1.setLayout(new FillLayout()); new Text(child1,SWT.MULTI).setText("窗口1"); Composite child2 = new Composite(form, SWT.NONE); child2.setLayout(new FillLayout()); new Text(child2,SWT.MULTI).setText("窗口2"); form.setWeights(new int[]{30,70}); shell.pack(); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()){ display.sleep(); } } display.dispose(); } }
时间: 2024-10-10 16:13:44