javafx.scene.control.ComboBox Java Examples
The following examples show how to use
javafx.scene.control.ComboBox.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnumPropertyControl.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void createComponents(@NotNull HBox container) { super.createComponents(container); enumComboBox = new ComboBox<>(); enumComboBox.prefWidthProperty() .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT)); FxControlUtils.onSelectedItemChange(enumComboBox, this::change); FxUtils.addClass(enumComboBox, CssClasses.PROPERTY_CONTROL_COMBO_BOX); FxUtils.addChild(container, enumComboBox); }
Example #2
Source File: RTToleranceEditor.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public RTToleranceEditor(PropertySheet.Item parameter) { if (!(parameter instanceof RTToleranceParameter)) throw new IllegalArgumentException(); // The value field valueField = new TextField(); // The combo box ObservableList<String> options = FXCollections.observableArrayList("Absolute (sec)", "Relative (%)"); comboBox = new ComboBox<String>(options); // FlowPane setting setHgap(10); // Add the elements getChildren().addAll(valueField, comboBox); }
Example #3
Source File: EthernetStreamTest.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * Fill Ethernet mac information */ private void setEthernetMacInfo() { clickOn("#protocolDataTab"); waitForNode("Media Access Protocol"); clickOn("Media Access Protocol"); waitForNode("#macDstAddress"); interact(() -> { TextField macDstAddress = find(("#macDstAddress")); macDstAddress.setText("12:00:00:00:00:22"); ComboBox dstMode = find("#macDstMode"); dstMode.getSelectionModel().select("Fixed"); TextField macSrcAddress = find(("#macSrcAddress")); macSrcAddress.setText("22:00:00:00:00:00"); ComboBox srcMode = find("#macsrcMode"); srcMode.getSelectionModel().select("Increment"); }); }
Example #4
Source File: GUIUtil.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
@NotNull public static <T> ListCell<T> getComboBoxButtonCell(String title, ComboBox<T> comboBox, Boolean hideOriginalPrompt) { return new ListCell<>() { @Override protected void updateItem(T item, boolean empty) { super.updateItem(item, empty); // See https://github.com/jfoenixadmin/JFoenix/issues/610 if (hideOriginalPrompt) this.setVisible(item != null || !empty); if (empty || item == null) { setText(title); } else { setText(comboBox.getConverter().toString(item)); } } }; }
Example #5
Source File: DataImporterController.java From curly with Apache License 2.0 | 6 votes |
private void setTableData(List<List<String>> data) { tableData = new ObservableListWrapper<>(data); int numberOfColumns = data.stream().map(List::size).reduce(Math::max).orElse(0); contentTable.getColumns().clear(); colMapping = new ArrayList<>(); for (int i = 0; i < numberOfColumns; i++) { colMapping.add(DONT_USE); TableColumn<List<String>, String> column = new TableColumn<>(); final int index = i; ComboBox<String> selector = generateVariableSelector(); selector.getSelectionModel().selectedItemProperty(). addListener((prop, oldValue, newValue) -> colMapping.set(index, newValue)); column.setGraphic(selector); column.setCellValueFactory((TableColumn.CellDataFeatures<List<String>, String> param) -> { List<String> row = param.getValue(); String value = row.size() > index ? row.get(index) : null; return new SimpleStringProperty(value); }); contentTable.getColumns().add(column); } contentTable.setItems(tableData); }
Example #6
Source File: PmMap.java From SmartCity-ParkingManagement with Apache License 2.0 | 6 votes |
public void createRoutePane() { routeVbox = addVBox("select route"); fromLocation = new ComboBox<String>(); fromLocation.setOnAction(λ -> map.hideDirectionsPane()); toLocation = new ComboBox<String>(); toLocation.setOnAction(λ -> map.hideDirectionsPane()); final Button btn = new Button("draw"); btn.setOnAction(e -> { if (toLocation.getSelectionModel().getSelectedItem() == null || fromLocation.getSelectionModel().getSelectedItem() == null) return; final MyMarker to = getMarkerByTitle(toLocation.getSelectionModel().getSelectedItem()), from = getMarkerByTitle(fromLocation.getSelectionModel().getSelectedItem()); directionsService.getRoute( new DirectionsRequest(from.lat.getLatitude() + ", " + from.lat.getLongitude(), to.lat.getLatitude() + ", " + to.lat.getLongitude(), TravelModes.DRIVING), this, new DirectionsRenderer(true, mapComponent.getMap(), directionsPane)); }); final Button removeBtn = new Button("remove line"); removeBtn.setOnAction(λ -> map.hideDirectionsPane()); routeVbox.getChildren().addAll(fromLocation, toLocation, btn, removeBtn); }
Example #7
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
public static boolean setStyle(Node node, String style) { try { if (node == null) { return false; } if (node instanceof ComboBox) { ComboBox c = (ComboBox) node; c.getEditor().setStyle(style); } else { node.setStyle(style); } return true; } catch (Exception e) { return false; } }
Example #8
Source File: CreateTerrainDialog.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
public CreateTerrainDialog(@NotNull final TreeNode<?> parentNode, @NotNull final NodeTree<?> nodeTree) { this.parentNode = parentNode; this.nodeTree = nodeTree; final ComboBox<Integer> totalSizeComboBox = getTotalSizeComboBox(); totalSizeComboBox.getSelectionModel().select(DEFAULT_TOTAL_SIZE); final ComboBox<Integer> patchSizeComboBox = getPatchSizeComboBox(); patchSizeComboBox.getSelectionModel().select(DEFAULT_PATH_SIZE); final ComboBox<Integer> alphaBlendTextureSizeComboBox = getAlphaBlendTextureSizeComboBox(); alphaBlendTextureSizeComboBox.getSelectionModel().select(DEFAULT_BLEND_TEXTURE_SIZE); final ComboBox<HeightMapType> heightMapTypeComboBox = getHeightMapTypeComboBox(); heightMapTypeComboBox.getSelectionModel().select(HeightMapType.FLAT); updatePathSizeValues(); }
Example #9
Source File: SwingDialog.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private JFXPanel createJFXPanel(){ final JFXPanelEx panel = new JFXPanelEx(); Platform.runLater(new Runnable() { @Override public void run() { final VBox vbox = new VBox(); final ComboBox<String> combo = new ComboBox<String>(); for (int i = 0; i< 101; i++){ combo.getItems().add("text" + i); } vbox.getChildren().addAll(combo); final Scene scene = new Scene(vbox); panel.setScene(scene); }; }); return panel; }
Example #10
Source File: JavaFXComboBoxTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void selectMultipleDuplicateOption() { @SuppressWarnings("unchecked") ComboBox<String> comboNode = (ComboBox<String>) getPrimaryStage().getScene().getRoot().lookup(".combo-box"); IJavaFXElement comboBox = combos.get(0); Platform.runLater(() -> { comboNode.getItems().add(3, "Option 2"); comboNode.getItems().add(5, "Option 2"); comboBox.marathon_select("Option 2(2)"); }); new Wait("Waiting for combo box option to be set.") { @Override public boolean until() { return comboNode.getSelectionModel().getSelectedIndex() == 5; } }; }
Example #11
Source File: RevolutForm.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
ComboBox<Country> addCountrySelection() { HBox hBox = new HBox(); hBox.setSpacing(5); ComboBox<Country> countryComboBox = new JFXComboBox<>(); hBox.getChildren().add(countryComboBox); addTopLabelWithVBox(gridPane, ++gridRow, Res.get("payment.bank.country"), hBox, 0); countryComboBox.setPromptText(Res.get("payment.select.bank.country")); countryComboBox.setConverter(new StringConverter<>() { @Override public String toString(Country country) { return country.name + " (" + country.code + ")"; } @Override public Country fromString(String s) { return null; } }); return countryComboBox; }
Example #12
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 6 votes |
public String getComboBoxText(ComboBox<?> comboBox, int index, boolean appendText) { if (index == -1) { return null; } String original = getComboBoxItemText(comboBox, index); String itemText = original; int suffixIndex = 0; for (int i = 0; i < index; i++) { String current = getComboBoxItemText(comboBox, i); if (current.equals(original)) { if (appendText) { itemText = String.format("%s(%d)", original, ++suffixIndex); } else { itemText = original; } } } return itemText; }
Example #13
Source File: CreateTerrainDialog.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * 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)); } }
Example #14
Source File: RotateOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void restoreStateFrom() { ComboBox<KeyStringValueItem<PredefinedSetOfPages>> rotationType = lookup("#rotationType").queryComboBox(); ComboBox<KeyStringValueItem<Rotation>> rotation = lookup("#rotation").queryComboBox(); Map<String, String> data = new HashMap<>(); data.put("rotation", Rotation.DEGREES_270.toString()); data.put("rotationType", PredefinedSetOfPages.EVEN_PAGES.toString()); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.restoreStateFrom(data)); assertEquals(Rotation.DEGREES_270, rotation.getSelectionModel().getSelectedItem().getKey()); assertEquals(PredefinedSetOfPages.EVEN_PAGES, rotationType.getSelectionModel().getSelectedItem().getKey()); }
Example #15
Source File: RegisterController.java From Sword_emulator with GNU General Public License v3.0 | 5 votes |
public RegisterController(GridPane registerPane, ComboBox<String> registerModeBox, Machine machine) { this.registerPane = registerPane; this.machine = machine; this.registerModeBox = registerModeBox; //machine.addRegisterListener(this); initView(); TimingRenderer.register(this); }
Example #16
Source File: UIBooleanMenuItem.java From tcMenu with Apache License 2.0 | 5 votes |
@Override protected int internalInitPanel(GridPane pane, int idx) { idx++; pane.add(new Label("Responses"), 0, idx); ObservableList<BooleanNaming> list = FXCollections.observableArrayList(BooleanNaming.values()); namingBox = new ComboBox<>(list); namingBox.getSelectionModel().select(getMenuItem().getNaming()); namingBox.valueProperty().addListener((observable, oldValue, newValue) -> callChangeConsumer()); pane.add(namingBox, 1, idx); return idx; }
Example #17
Source File: FormBuilder.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static <T> Tuple4<Label, TextField, Label, ComboBox<T>> addTopLabelTextFieldAutocompleteComboBox( GridPane gridPane, int rowIndex, String titleTextfield, String titleCombobox ) { return addTopLabelTextFieldAutocompleteComboBox(gridPane, rowIndex, titleTextfield, titleCombobox, 0); }
Example #18
Source File: TableAttributeKeyValueTemplate.java From Spring-generator with MIT License | 5 votes |
public void setTemplateValue(String templateValue) { this.templateValue = templateValue; if (this.template == null) { this.template = new ComboBox<>(); this.template.setValue(templateValue); } }
Example #19
Source File: SetCustomController.java From Spring-generator with MIT License | 5 votes |
/** * 添加自定义属性 * * @param event */ public void onAddPropertyToTable(ActionEvent event) { LOG.debug("执行添加自定义属性..."); ComboBox<String> comboBox = new ComboBox<>(); comboBox.promptTextProperty().bind(Main.LANGUAGE.get(LanguageKey.SET_CBO_TEMPLATE)); comboBox.prefWidthProperty().bind(tdTemplate.widthProperty()); comboBox.setEditable(true); comboBox.getItems().addAll(indexController.getTemplateNameItems()); TableAttributeKeyValueTemplate attribute = new TableAttributeKeyValueTemplate(txtKey.getText(), txtPackageName.getText(), txtClassName.getText(), Constant.JAVA_SUFFIX, comboBox); tblPropertyValues.add(attribute); LOG.debug("添加自定义属性-->成功!"); }
Example #20
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 5 votes |
public static void setEditorStyle(final ComboBox box, final String style) { box.getEditor().setStyle(style); // Platform.runLater(new Runnable() { // @Override // public void run() { // box.getEditor().setStyle(style); // } // }); }
Example #21
Source File: FormBuilder.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static <T> Tuple3<VBox, Label, ComboBox<T>> addTopLabelComboBox(String title, String prompt, int top) { Label label = getTopLabel(title); VBox vBox = getTopLabelVBox(top); final JFXComboBox<T> comboBox = new JFXComboBox<>(); comboBox.setPromptText(prompt); vBox.getChildren().addAll(label, comboBox); return new Tuple3<>(vBox, label, comboBox); }
Example #22
Source File: LinkConfigurationWidget.java From BowlerStudio with GNU General Public License v3.0 | 5 votes |
private void setShaftType(Button editShaft, Button newShaft, final ComboBox<String> shaftSize, String selectedItem) { shaftSize.getItems().clear(); if (selectedItem == null) return; for (String s : Vitamins.listVitaminSizes(selectedItem)) { shaftSize.getItems().add(s); } newShaft.setText("New " + selectedItem); // editShaft.setText("Edit "+ conf.getShaftSize()); }
Example #23
Source File: DataManipulationUI.java From SONDY with GNU General Public License v3.0 | 5 votes |
public final void filterUI(){ GridPane gridLEFT = new GridPane(); // Labels Label stopwordsLabel = new Label("Stop words removal"); UIUtils.setSize(stopwordsLabel, Main.columnWidthLEFT/2, 24); Label resizingLabel = new Label("Resizing"); UIUtils.setSize(resizingLabel, Main.columnWidthLEFT/2, 24); gridLEFT.add(stopwordsLabel,0,0); gridLEFT.add(new Rectangle(0,3),0,1); gridLEFT.add(resizingLabel,0,2); // Values stopwordLists = new StopwordSets(); stopwordListsCheckComboBox = new CheckComboBox<>(stopwordLists.availableSets); stopwordListsCheckComboBox.setStyle("-fx-font-size: 12px;"); stopwordListsCheckComboBox.skinProperty().addListener(new ChangeListener<Skin>() { @Override public void changed(ObservableValue<? extends Skin> observable, Skin oldValue, Skin newValue) { if(oldValue==null && newValue!=null){ CheckComboBoxSkin skin = (CheckComboBoxSkin)newValue; ComboBox combo = (ComboBox)skin.getChildren().get(0); combo.setPrefWidth(Main.columnWidthLEFT/2); combo.setMaxWidth(Double.MAX_VALUE); } } }); // stopwordListsCheckComboBox.setMaxWidth(Double.MAX_VALUE); // UIUtils.setSize(stopwordListsCheckComboBox,Main.columnWidthLEFT/2, 24); gridLEFT.add(stopwordListsCheckComboBox,1,0); resizeSlider = new RangeSlider(); resizeSlider.setBlockIncrement(0.1); UIUtils.setSize(resizeSlider,Main.columnWidthLEFT/2, 24); resizeSlider.resize(Main.columnWidthLEFT/2, 24); gridLEFT.add(resizeSlider,1,2); HBox filterDatasetBOTH = new HBox(5); filterDatasetBOTH.getChildren().addAll(gridLEFT,createFilterButton()); grid.add(filterDatasetBOTH,0,11); }
Example #24
Source File: ParetoTest.java From charts with Apache License 2.0 | 5 votes |
private void initParts(){ paretoPanel = new ParetoPanel(createTestData1()); circleColor = new ColorPicker(); circleColor.setValue(Color.BLUE); graphColor = new ColorPicker(); graphColor.setValue(Color.BLACK); fontColor = new ColorPicker(); fontColor.setValue(Color.BLACK); smoothing = new CheckBox("Smoothing"); realColor = new CheckBox("AutoSubColor"); showSubBars = new CheckBox("ShowSubBars"); singeSubBarCentered = new CheckBox("SingleSubBarCenterd"); circleSize = new Slider(1,60,20); valueHeight = new Slider(0,80,20); textHeight = new Slider(0,80,40); barSpacing = new Slider(1,50,5); pathHeight = new Slider(0,80,65); barColors = new ArrayList<>(); backButton = new Button("Back to last layer"); exampeColorTheme = createRandomColorTheme(20); paretoPanel.addColorTheme("example",exampeColorTheme); colorTheme = new ComboBox<>(); colorTheme.getItems().addAll(paretoPanel.getColorThemeKeys()); mainBox = new HBox(); menu = new VBox(); pane = new Pane(); }
Example #25
Source File: UomEditorController.java From OEE-Designer with MIT License | 5 votes |
private void selectSymbol(UnitOfMeasure uom, ComboBox<String> combobox) { if (combobox == null) { return; } combobox.getSelectionModel().select(uom.toDisplayString()); }
Example #26
Source File: RoleSelectionTest.java From triplea with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private SingleSelectionModel<String> createSelectionModelMock( final ComboBox<String> comboBox, final int index) { final SingleSelectionModel<String> mock = mock(SingleSelectionModel.class); when(comboBox.getSelectionModel()).thenReturn(mock); when(mock.getSelectedIndex()).thenReturn(index); return mock; }
Example #27
Source File: ImageBackground.java From Quelea with GNU General Public License v3.0 | 5 votes |
@Override public void setThemeForm(ColorPicker backgroundColorPicker, ComboBox<String> backgroundTypeSelect, TextField backgroundImgLocation, TextField backgroundVidLocation, Slider vidHueSlider, CheckBox vidStretchCheckbox) { backgroundTypeSelect.getSelectionModel().select(LabelGrabber.INSTANCE.getLabel("image.theme.label")); backgroundImgLocation.setText(imageName); backgroundColorPicker.setValue(Color.BLACK); backgroundColorPicker.fireEvent(new ActionEvent()); backgroundVidLocation.clear(); vidHueSlider.setValue(0); vidStretchCheckbox.setSelected(false); }
Example #28
Source File: OptionStage.java From xframium-java with GNU General Public License v3.0 | 5 votes |
private void buildComboBoxes () { spyFolder = prefs.get ("SpyFolder", ""); String fileText = prefs.get ("ReplayFile", ""); fileComboBox = new ComboBox<> (getSessionFiles (spyFolder)); fileComboBox.setPrefWidth (COMBO_BOX_WIDTH); fileComboBox.setVisibleRowCount (15); fileComboBox.getSelectionModel ().select (fileText); String serverSelected = prefs.get ("ServerName", ""); serverComboBox = serverSitesListStage.getComboBox (); serverComboBox.setPrefWidth (COMBO_BOX_WIDTH); serverComboBox.setVisibleRowCount (5); serverComboBox.getSelectionModel ().select (serverSelected); String clientSelected = prefs.get ("ClientName", ""); clientComboBox = clientSitesListStage.getComboBox (); clientComboBox.setPrefWidth (COMBO_BOX_WIDTH); clientComboBox.setVisibleRowCount (5); clientComboBox.getSelectionModel ().select (clientSelected); editServersButton = serverSitesListStage.getEditButton (); editServersButton.setStyle (EDIT_BUTTON_FONT_SIZE); editServersButton.setMinWidth (EDIT_BUTTON_WIDTH); editClientsButton = clientSitesListStage.getEditButton (); editClientsButton.setStyle (EDIT_BUTTON_FONT_SIZE); editClientsButton.setMinWidth (EDIT_BUTTON_WIDTH); editLocationButton = new Button ("Folder..."); editLocationButton.setStyle (EDIT_BUTTON_FONT_SIZE); editLocationButton.setMinWidth (EDIT_BUTTON_WIDTH); }
Example #29
Source File: GroupAndDatasetStructure.java From paintera with GNU General Public License v2.0 | 5 votes |
public Node createNode() { final TextField groupField = new TextField(group.getValue()); groupField.setMinWidth(0); groupField.setMaxWidth(Double.POSITIVE_INFINITY); groupField.setPromptText(groupPromptText); groupField.textProperty().bindBidirectional(group); final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices); datasetDropDown.setPromptText(datasetPromptText); datasetDropDown.setEditable(false); datasetDropDown.valueProperty().bindBidirectional(dataset); datasetDropDown.setMinWidth(groupField.getMinWidth()); datasetDropDown.setPrefWidth(groupField.getPrefWidth()); datasetDropDown.setMaxWidth(groupField.getMaxWidth()); datasetDropDown.disableProperty().bind(this.isDropDownReady); final GridPane grid = new GridPane(); grid.add(groupField, 0, 0); grid.add(datasetDropDown, 0, 1); GridPane.setHgrow(groupField, Priority.ALWAYS); GridPane.setHgrow(datasetDropDown, Priority.ALWAYS); final Button button = new Button("Browse"); button.setOnAction(event -> { Optional.ofNullable(onBrowseClicked.apply(group.getValue(), grid.getScene())).ifPresent(group::setValue); }); grid.add(button, 1, 0); groupField.effectProperty().bind( Bindings.createObjectBinding( () -> groupField.isFocused() ? this.textFieldNoErrorEffect : groupErrorEffect.get(), groupErrorEffect, groupField.focusedProperty() )); return grid; }
Example #30
Source File: GuiUtils.java From kafka-message-tool with MIT License | 5 votes |
public static <T> void resetComboboxValue(ComboBox<T> comboBox, T value) { // if value (reference to object) does not change as combobox value // but the internals of reference will change (eg. some field of object) // combobox will not reinitialize it , need to to clear and reset it manually if (comboBox.getValue() == value) { comboBox.setValue(null); } comboBox.setValue(value); }