同一组合的无线电组上的按钮正在获得箭头键的焦点

时间:2013-06-12 07:33:40

标签: java eclipse eclipse-plugin swt jface

在同一个复合材料上带有一组单选按钮的按钮,获得箭头键的焦点,该箭头键应该用于从无线电组中选择一个选项。

我们可以阻止PUSH按钮聚焦到箭头键。有什么办法吗?

以下是示例代码。

import org.eclipse.swt.SWT;

import org.eclipse.swt.widgets.Button;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.widgets.Text;

public class SWTButtons {

public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell(display);   

    //radio
    Button[] radioButtons = new Button[3];
    radioButtons[0] = new Button(shell, SWT.RADIO);
    radioButtons[0].setSelection(true);
    radioButtons[0].setText("Choice 1");
    radioButtons[0].setLocation(50,150);
    radioButtons[0].pack();

    radioButtons[1] = new Button(shell, SWT.RADIO);
    radioButtons[1].setText("Choice 2");
    radioButtons[1].setLocation(120,150);
    radioButtons[1].pack();

    radioButtons[2] = new Button(shell, SWT.RADIO);
    radioButtons[2].setText("Choice 3");
    radioButtons[2].setLocation(190,150);
    radioButtons[2].pack();
    //Text
    Text textBox =  new Text(shell, SWT.BORDER);
    textBox.setText("Test");
    textBox.setLocation(260,  150);
    textBox.pack();

    //push button
    Button pushButton = new Button(shell, SWT.PUSH);
    pushButton.setLocation(100, 250);
    pushButton.setText("Get Value (push button)");
    pushButton.pack();


    shell.setSize(500,500);
    shell.open ();
    while (!shell.isDisposed ()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}
}

0 个答案:

没有答案