本文整理汇总了Java中javafx.scene.control.ComboBox.isEditable方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.isEditable方法的具体用法?Java ComboBox.isEditable怎么用?Java ComboBox.isEditable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ComboBox
的用法示例。
在下文中一共展示了ComboBox.isEditable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: focusLost
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
@Override public void focusLost(RFXComponent next) {
ComboBox<?> comboBox = (ComboBox<?>) node;
Object selectedItem = comboBox.getSelectionModel().getSelectedItem();
if (comboBox.isEditable() && comboBox.getEditor().getText()
.equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) {
return;
} else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) {
return;
}
if (!comboBox.isEditable()) {
recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true));
} else {
String editorText = comboBox.getEditor().getText();
String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false);
if (editorText.equals(selectedItemText)) {
recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true));
} else {
recorder.recordSelect(this, editorText);
}
}
}
示例2: marathon_select
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
@Override public boolean marathon_select(String value) {
ComboBox<?> comboBox = (ComboBox<?>) getComponent();
String text = stripHTMLTags(value);
int selectedItem = getComboBoxItemIndex(comboBox, text);
if (selectedItem == -1) {
if (comboBox.isEditable()) {
comboBox.getEditor().setText(value);
return true;
}
return false;
}
comboBox.getSelectionModel().select(selectedItem);
return true;
}
示例3: customize
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
/**
* This will install an {@link EventHandler} that monitors the
* {@link KeyEvent} events to enable the "prefix selection" feature.
* The {@link EventHandler} will only be installed if the {@link ComboBox}
* is <b>not</b> editable.
*
* @param comboBox
* The {@link ComboBox} that should be customized
*
* @see PrefixSelectionCustomizer
*/
public static void customize(ComboBox<?> comboBox) {
if (!comboBox.isEditable()) {
comboBox.addEventHandler(KeyEvent.KEY_PRESSED, handler);
}
comboBox.editableProperty().addListener((o, oV, nV) -> {
if (!nV) {
comboBox.addEventHandler(KeyEvent.KEY_PRESSED, handler);
} else {
comboBox.removeEventHandler(KeyEvent.KEY_PRESSED, handler);
}
});
}