Combo 类型未定义方法 getSelectedItem()

The method getSelectedItem() is undefined for the type Combo

我是 Java Basic 的初学者,我对 getSelectedItem() 有疑问。 之前发布了同样的问题,但它无助于解决我的问题,因为 Eclipse 总是 returns :

The method getSelectedItem() is undefined for the type Combo

我的完整代码:

public class FormObjects {

protected Shell shell;
private Text txtComboBoxItem;

/**
 * Launch the application.
 * @param args
 */
public static void main(String[] args) {
    try {
        FormObjects window = new FormObjects();
        window.open();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

/**
 * Open the window.
 */
public void open() {
    Display display = Display.getDefault();
    createContents();
    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

/**
 * Create contents of the window.
 */
protected void createContents() {
    shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("SWT Application");

    Combo comboOne = new Combo(shell, SWT.NONE);
    comboOne.setItems(new String[] {"C Sharp", "Java", "PHP", "Visual Basic", ".NET"});
    comboOne.setBounds(30, 50, 91, 23);

    Button btnComboBox = new Button(shell, SWT.NONE);
    btnComboBox.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String itemText = (String)comboOne.getSelectedItem();
            txtComboBoxItem.setText(itemText);
        }
    });
    btnComboBox.setBounds(147, 48, 130, 25);
    btnComboBox.setText("Get Drop Down Item");

    txtComboBoxItem = new Text(shell, SWT.BORDER);
    txtComboBoxItem.setBounds(304, 50, 101, 21);

}
}

我可以使用 setText() 来解决我的问题。谢谢大家!