代码之家  ›  专栏  ›  技术社区  ›  App Work

在SWT中,我如何将一个按钮置于另一个按钮的前面

  •  1
  • App Work  · 技术社区  · 9 年前

    如何在SWT中将“NewButton”置于“Button”之前?请参考下图:换句话说,如何将“Button”发送到“NewButton”的后面? enter image description here

    1 回复  |  直到 9 年前
        1
  •  2
  •   App Work    9 年前

    enter image description here

        public static void main(String[] args) {
    
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setBounds(10,10,300,300);
        Button b =new Button(shell, SWT.NONE);
        b.setText("Button");
        b.setBounds(60,60,80,80);
        Button button = new Button(shell, SWT.PUSH);
        button.setText("NewButton");
    
        button.setBounds(120,120,90,90);
        button.moveAbove(b); shell.open();
    
        while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
        }