在SWT中,如何在另一个按钮前面放一个按钮

时间:2015-09-24 01:20:55

标签: java user-interface swt eclipse-rcp

如何在SWT中的“按钮”前面加上“NewButton”?请参考下图:换句话说,如何将“按钮”发送到“NewButton”的背面? enter image description here

1 个答案:

答案 0 :(得分:2)

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();
    }