本文整理汇总了Java中javafx.scene.control.SingleSelectionModel类的典型用法代码示例。如果您正苦于以下问题:Java SingleSelectionModel类的具体用法?Java SingleSelectionModel怎么用?Java SingleSelectionModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingleSelectionModel类属于javafx.scene.control包,在下文中一共展示了SingleSelectionModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePathSizeValues
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
/**
* Update a list of available path sizes.
*/
@FXThread
private void updatePathSizeValues() {
final ComboBox<Integer> pathSizeComboBox = getPatchSizeComboBox();
final SingleSelectionModel<Integer> selectionModel = pathSizeComboBox.getSelectionModel();
final Integer current = selectionModel.getSelectedItem();
final ObservableList<Integer> items = pathSizeComboBox.getItems();
items.clear();
final ComboBox<Integer> totalSizeComboBox = getTotalSizeComboBox();
final Integer naxValue = totalSizeComboBox.getSelectionModel().getSelectedItem();
for (final Integer value : PATCH_SIZE_VARIANTS) {
if (value >= naxValue) break;
items.add(value);
}
if (items.contains(current)) {
selectionModel.select(current);
} else {
selectionModel.select(items.get(items.size() - 1));
}
}
示例2: createComponents
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void createComponents() {
super.createComponents();
comboBox = new ComboBox<>();
comboBox.prefWidthProperty().bind(widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));
comboBox.getItems().addAll(FONTS);
comboBox.setVisibleRowCount(20);
comboBox.setConverter(STRING_CONVERTER);
comboBox.setEditable(true);
final SingleSelectionModel<Font> selectionModel = comboBox.getSelectionModel();
selectionModel.selectedItemProperty().addListener((observable, oldValue, newValue) -> change());
final AutoCompletionTextFieldBinding<Font> binding =
new AutoCompletionTextFieldBinding<>(comboBox.getEditor(),
SuggestionProvider.create(comboBox.getItems()), STRING_CONVERTER);
binding.setOnAutoCompleted(event -> selectionModel.select(event.getCompletion()));
FXUtils.addClassesTo(comboBox.getEditor(), CSSClasses.TRANSPARENT_TEXT_FIELD, CSSClasses.TEXT_FIELD_IN_COMBO_BOX);
FXUtils.addClassTo(comboBox, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
FXUtils.addToPane(comboBox, this);
}
示例3: processOpen
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void processOpen(@NotNull final ResourceElement element) {
super.processOpen(element);
final ComboBox<String> textureParamNameBox = getTextureParamNameComboBox();
final SingleSelectionModel<String> selectionModel = textureParamNameBox.getSelectionModel();
final String textureParamName = selectionModel.getSelectedItem();
final CheckBox transformBox = getApplyLightingTransformCheckBox();
final AssetManager assetManager = EDITOR.getAssetManager();
final Path file = element.getFile();
final Path assetFile = getAssetFile(file);
if (assetFile == null) {
throw new RuntimeException("AssetFile can't be null.");
}
final Material material = assetManager.loadAsset(new MaterialKey(toAssetPath(assetFile)));
final Consumer<ParticlesMaterial> consumer = getConsumer();
consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected()));
}
示例4: processOpenFile
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
/**
* Handle the request to open a file.
*/
@FXThread
private void processOpenFile(@NotNull final RequestedOpenFileEvent event) {
final Path file = event.getFile();
final ConcurrentObjectDictionary<Path, Tab> openedEditors = getOpenedEditors();
final Tab tab = DictionaryUtils.getInReadLock(openedEditors, file, ObjectDictionary::get);
if (tab != null) {
final SingleSelectionModel<Tab> selectionModel = getSelectionModel();
selectionModel.select(tab);
return;
}
EditorUtil.incrementLoading();
EXECUTOR_MANAGER.addBackgroundTask(() -> processOpenFileImpl(event, file));
}
示例5: applyValues
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
private void applyValues() {
inConnectionPortField.setText(String.valueOf(ApplicationPreferences.getProperty(
NetworkProperties.INCOMING_CONNECTION_PORT, ClientProperties.TCP_PORT)));
final boolean randomizePortOnStart = ApplicationPreferences.getProperty(
NetworkProperties.RANDOMIZE_CONNECTION_PORT, false);
randomPortEachStartCheck.setSelected(randomizePortOnStart);
final boolean upnpPortMappingEnabled = ApplicationPreferences.getProperty(
NetworkProperties.ENABLE_UPNP_PORT_MAPPING, false);
upnpPortMappingCheck.setSelected(upnpPortMappingEnabled);
final String interfaceName = ApplicationPreferences.getProperty(
NetworkProperties.NETWORK_INTERFACE_NAME, NetworkUtilities.DEFAULT_NETWORK_INTERFACE);
final SingleSelectionModel<String> comboSelectionModel = networkInterfaceSelectionCombo.getSelectionModel();
if(networkInterfaceSelectionCombo.getItems().contains(interfaceName)) {
comboSelectionModel.select(interfaceName);
}
else {
comboSelectionModel.select(NetworkUtilities.DEFAULT_NETWORK_INTERFACE);
}
}
示例6: mouseClicked
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override protected void mouseClicked(MouseEvent me) {
TabPane tp = (TabPane) node;
SingleSelectionModel<Tab> selectionModel = tp.getSelectionModel();
Tab selectedTab = selectionModel.getSelectedItem();
if (selectedTab != null && prevSelection != selectionModel.getSelectedIndex()) {
recorder.recordSelect(this, getTextForTab(tp, selectedTab));
}
prevSelection = selectionModel.getSelectedIndex();
}
示例7: bind
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
public <T> void bind(ComboBox<T> box) {
box.getSelectionModel()
.selectedItemProperty()
.addListener((ob, o, n) -> add(Undoable.create(
UndoUtil.<SingleSelectionModel<T>, T> weakConsumer(box.getSelectionModel(), SingleSelectionModel::select),
n, o)));
}
示例8: handleFilterChanged
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
private void handleFilterChanged(String newValue) {
if (filteredItems != null) {
Predicate<T> p = filter.get().isEmpty() ? null :
s -> comparator.matches(filter.get(), s);
filteredItems.setPredicate(p);
}
if (!StringUtils.isBlank(newValue)) {
comboBox.show();
if (StringUtils.isBlank(filter.get())) {
restoreOriginalItems();
}
else {
showTooltip();
SingleSelectionModel<T> selectionModel = comboBox.getSelectionModel();
if (filteredItems.isEmpty()) {
selectionModel.clearSelection();
}
else {
selectionModel.select(0);
}
}
}
else {
comboBox.getTooltip().hide();
restoreOriginalItems();
}
}
示例9: changeImpl
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void changeImpl() {
final ComboBox<String> comboBox = getComboBox();
final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();
setPropertyValue(selectionModel.getSelectedItem());
super.changeImpl();
}
示例10: changeImpl
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void changeImpl() {
final ComboBox<Font> comboBox = getComboBox();
final SingleSelectionModel<Font> selectionModel = comboBox.getSelectionModel();
setPropertyValue(selectionModel.getSelectedItem());
super.changeImpl();
}
示例11: changeImpl
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void changeImpl() {
final ComboBox<T> enumComboBox = getEnumComboBox();
final SingleSelectionModel<T> selectionModel = enumComboBox.getSelectionModel();
setPropertyValue(selectionModel.getSelectedItem());
super.changeImpl();
}
示例12: buildAdditionalDisableCondition
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() {
final ComboBox<String> comboBox = getTextureParamNameComboBox();
final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();
final ReadOnlyObjectProperty<String> itemProperty = selectionModel.selectedItemProperty();
final ObservableBooleanValue parent = super.buildAdditionalDisableCondition();
return Bindings.and(parent, itemProperty.isNull().or(itemProperty.isEqualTo("")));
}
示例13: validate
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {
final ComboBox<String> comboBox = getTextureParamNameComboBox();
final ObservableList<String> items = comboBox.getItems();
items.clear();
final Path file = element == null ? null : element.getFile();
if (file != null && !Files.isDirectory(file)) {
final AssetManager assetManager = EDITOR.getAssetManager();
final Path assetFile = getAssetFile(file);
if (assetFile == null) {
throw new RuntimeException("AssetFile can't be null.");
}
final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));
final Material material = assetManager.loadAsset(materialKey);
final MaterialDef materialDef = material.getMaterialDef();
final Collection<MatParam> materialParams = materialDef.getMaterialParams();
materialParams.stream()
.filter(param -> param.getVarType() == VarType.Texture2D)
.filter(matParam -> material.getTextureParam(matParam.getName()) != null)
.forEach(filtred -> items.add(filtred.getName()));
final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();
if (!items.isEmpty()) {
selectionModel.select(0);
} else {
selectionModel.select(null);
}
}
super.validate(warningLabel, element);
}
示例14: change
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
/**
* Update selected {@link Enum} value.
*/
@FXThread
private void change() {
if (isIgnoreListener()) return;
final ComboBox<E> enumComboBox = getEnumComboBox();
final SingleSelectionModel<E> selectionModel = enumComboBox.getSelectionModel();
final E newValue = selectionModel.getSelectedItem();
changed(newValue, getPropertyValue());
}
示例15: reload
import javafx.scene.control.SingleSelectionModel; //导入依赖的package包/类
@Override
@FXThread
protected void reload() {
final E element = getPropertyValue();
final ComboBox<E> enumComboBox = getEnumComboBox();
final SingleSelectionModel<E> selectionModel = enumComboBox.getSelectionModel();
selectionModel.select(element);
}