滚动并自动调整大小

时间:2015-06-16 08:06:09

标签: java user-interface swt

我尝试使滚动工作,我还想自动调整窗口中的窗口和内容。我的界面将要有几个复合块来解析一些信息,块内的字段是静态的,它们在同一个块中总是相同的字段`

public void open() {


    Display display = Display.getDefault();
    createContents();
    shell.addListener (SWT.Resize,  new Listener () {
        public void handleEvent (Event e) {
          Rectangle rect = shell.getClientArea ();
          System.out.println(rect);
        }
      });

    shell.open();
    shell.layout();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

/**
 * Create contents of the window.
 */
protected void createContents() {

    shell = new Shell(SWT.SHELL_TRIM |SWT.V_SCROLL | SWT.H_SCROLL);
    shell.addMouseWheelListener(new MouseWheelListener() {
        public void mouseScrolled(MouseEvent e) {
        }
    });
    shell.setSize(1546, 878);

    shell.setBackground(SWTResourceManager.getColor(255, 255, 255));
    shell.setMaximized(true);
    shell.setMinimumSize(1500, 600);
    shell.setText("Test App for nothing");
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));

0 个答案:

没有答案