1

How to open ComboBox automatically?

I have an editable ComboBox. I want it to be opened automatically, without forcing a user to click on it. How can it be done? I've tried to make something like this:

testButton.fireEvent(new Event(ComboBox.ON_SHOWN));

But it does not work as I need: in the output I can see messages which signals that ON_SHOWN event was fired, but graphically my comboBox is still closed. Also, i've tried

testButton.fireEvent(new Event(ComboBox.ON_SHOWING));

but this shows no reaction at all. As well as

testButton.fireEvent(new Event(ComboBoxBase.ON_SHOWING));

and

testButton.fireEvent(new Event(ComboBoxBase.ON_SHOWN));

PS: saying opened comboBox I mean something like this:

4

2 回答 2

6

尝试

Button btn = new Button("Show combobox");
btn.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent event) {
        comboBox.show();
    }
});
于 2012-11-07T13:48:30.970 回答
-2

show();方法不适用于CheckComboBox

请让我们知道如何为 CheckComboBox 做同样的事情。

单击按钮时,CheckComboBox 应自动打开

于 2016-12-20T14:42:23.847 回答