List of usage examples for javafx.scene.control ComboBox ComboBox
public ComboBox()
From source file:Main.java
@Override public void start(final Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Color> cmb = new ComboBox<Color>(); cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE); cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() { @Override//from ww w . ja v a 2s.c o m public ListCell<Color> call(ListView<Color> p) { return new ListCell<Color>() { private final Rectangle rectangle; { setContentDisplay(ContentDisplay.GRAPHIC_ONLY); rectangle = new Rectangle(10, 10); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { rectangle.setFill(item); setGraphic(rectangle); } } }; } }); gridpane.add(cmb, 2, 0); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(final Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.WHITE); GridPane gridpane = new GridPane(); ComboBox<Color> cmb = new ComboBox<Color>(); cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE); cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() { @Override//w w w. ja v a 2 s. c o m public ListCell<Color> call(ListView<Color> p) { return new ListCell<Color>() { private final Rectangle rectangle; { setContentDisplay(ContentDisplay.GRAPHIC_ONLY); rectangle = new Rectangle(10, 10); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { rectangle.setFill(item); setGraphic(rectangle); } } }; } }); gridpane.add(cmb, 2, 0); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("ComboBoxSample"); Scene scene = new Scene(new Group(), 450, 250); ComboBox emailComboBox = new ComboBox(); emailComboBox.getItems().addAll("A", "B", "C", "D", "E"); emailComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override//from w ww . j av a 2s. com public ListCell<String> call(ListView<String> param) { final ListCell<String> cell = new ListCell<String>() { { super.setPrefWidth(100); } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item); if (item.contains("A")) { setTextFill(Color.RED); } else if (item.contains("B")) { setTextFill(Color.GREEN); } else { setTextFill(Color.BLACK); } } else { setText(null); } } }; return cell; } }); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(emailComboBox, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:gov.va.isaac.gui.listview.operations.ParentReplace.java
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); root_.add(new Label("Replace: "), 0, 0); replaceOptions_ = new ComboBox<>(); replaceOptions_.setMaxWidth(Double.MAX_VALUE); replaceOptions_.setPromptText("-Populate the Concepts List-"); root_.add(ErrorMarkerUtils.setupErrorMarker(replaceOptions_, replaceOptionsInvalidString_), 1, 0); ComboBoxSetupTool.setupComboBox(replaceOptions_); root_.add(new Label("With Parent: "), 0, 1); withConcept_ = new ConceptNode(null, true); root_.add(withConcept_.getNode(), 1, 1); GridPane.setHgrow(withConcept_.getNode(), Priority.ALWAYS); FxUtils.preventColCollapse(root_, 0); initActionListeners();/*from w ww . j a va 2s . c o m*/ replaceOptions_.getItems().addAll(conceptList); }
From source file:account.management.controller.inventory.InsertStockController.java
public void addRow() { ComboBox<Product> select_item = new ComboBox(); select_item.setPromptText("Select Item"); select_item.setPrefWidth(190);//from w w w .j a v a2 s .co m select_item.setPrefHeight(25); new AutoCompleteComboBoxListener<>(select_item); select_item.setOnHiding((e) -> { Product a = select_item.getSelectionModel().getSelectedItem(); select_item.setEditable(false); select_item.getSelectionModel().select(a); }); select_item.setOnShowing((e) -> { select_item.setEditable(true); }); TextField qty = new TextField(); qty.setPromptText("Quantity"); qty.setPrefWidth(97); qty.setPrefHeight(25); TextField rate = new TextField(); rate.setPrefWidth(100); rate.setPrefHeight(25); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setPromptText("Purchase Rate"); } else { rate.setPromptText("Sell Rate"); } Button del = new Button("Delete"); HBox row = new HBox(); row.getChildren().addAll(select_item, qty, rate, del); row.setSpacing(10); row.setPadding(new Insets(0, 0, 0, 15)); this.conatiner.getChildren().add(row); del.setOnAction((e) -> { this.conatiner.getChildren().remove(row); this.add_row.setDisable(false); calculateTotal(); }); select_item.getItems().addAll(this.products_list); select_item.setOnAction((e) -> { qty.setText("0"); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_p_rate())); } else { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_s_rate())); } calculateTotal(); }); qty.setOnKeyReleased((e) -> { calculateTotal(); }); rate.setOnKeyReleased((e) -> { calculateTotal(); }); if (this.conatiner.getChildren().size() >= 8) { this.add_row.setDisable(true); return; } }
From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginComboBoxProperty.java
/** * @param name//from w ww. jav a 2 s . c om * @param stringConverter * * Constructor for ComboBox that displays a String * that must be derived/converted from its underlying value * * Allows a preexisting Label to be used */ protected PreferencesPluginComboBoxProperty(Label label, StringConverter<T> stringConverter) { super(label, new ComboBox<T>(), new SimpleObjectProperty<T>(), null, // validator handled below stringConverter, new PropertyAction<T, ComboBox<T>>() { @Override public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) { property.getProperty() .bind(property.getControl().getSelectionModel().selectedItemProperty()); } }, new PropertyAction<T, ComboBox<T>>() { @Override public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) { property.getControl().getSelectionModel().select(property.readFromPersistedPreferences()); } }, new PropertyAction<T, ComboBox<T>>() { @Override public void apply(PreferencesPluginProperty<T, ComboBox<T>> property) { GridPane.setHgrow(property.getLabel(), Priority.NEVER); GridPane.setFillWidth(property.getControl(), true); GridPane.setHgrow(property.getControl(), Priority.ALWAYS); } }); validator = new ValidBooleanBinding() { { bind(getProperty()); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (getProperty().getValue() == null) { this.setInvalidReason("null/unset/unselected " + name); logger.debug(getReasonWhyInvalid().get()); TextErrorColorHelper.setTextErrorColor(label); return false; } else { TextErrorColorHelper.clearTextErrorColor(label); } if (StringUtils.isEmpty(getStringConverter().convertToString(getProperty().getValue()))) { this.setInvalidReason("Invalid " + name); logger.debug(getReasonWhyInvalid().get()); TextErrorColorHelper.setTextErrorColor(label); return false; } else { TextErrorColorHelper.clearTextErrorColor(label); } this.clearInvalidReason(); return true; } }; control.setCellFactory(new Callback<ListView<T>, ListCell<T>>() { @Override public ListCell<T> call(ListView<T> param) { final ListCell<T> cell = new ListCell<T>() { @Override protected void updateItem(T c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String diplay = getStringConverter().convertToString(c); setText(diplay); } } }; return cell; } }); control.setButtonCell(new ListCell<T>() { @Override protected void updateItem(T c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String diplay = getStringConverter().convertToString(c); setText(diplay); } } }); }
From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java
@Override public void addFormForAddAccount() { gridRowFrom = gridRow + 1;/*from ww w. j a v a2 s . com*/ InputTextField holderNameInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account holder name:").second; holderNameInputTextField.setValidator(inputValidator); holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setHolderName(newValue); updateFromInputs(); }); ibanInputTextField = addLabelInputTextField(gridPane, ++gridRow, "IBAN:").second; ibanInputTextField.setValidator(ibanValidator); ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setIban(newValue); updateFromInputs(); }); bicInputTextField = addLabelInputTextField(gridPane, ++gridRow, "BIC:").second; bicInputTextField.setValidator(bicValidator); bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { sepaAccount.setBic(newValue); updateFromInputs(); }); addLabel(gridPane, ++gridRow, "Country of bank:"); HBox hBox = new HBox(); hBox.setSpacing(10); ComboBox<Country> countryComboBox = new ComboBox<>(); currencyComboBox = new ComboBox<>(); currencyTextField = new TextField(""); currencyTextField.setEditable(false); currencyTextField.setMouseTransparent(true); currencyTextField.setFocusTraversable(false); currencyTextField.setMinWidth(300); currencyTextField.setVisible(false); currencyTextField.setManaged(false); currencyComboBox.setVisible(false); currencyComboBox.setManaged(false); hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox); GridPane.setRowIndex(hBox, gridRow); GridPane.setColumnIndex(hBox, 1); gridPane.getChildren().add(hBox); countryComboBox.setPromptText("Select country of bank"); countryComboBox.setConverter(new StringConverter<Country>() { @Override public String toString(Country country) { return country.name + " (" + country.code + ")"; } @Override public Country fromString(String s) { return null; } }); countryComboBox.setOnAction(e -> { Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem(); sepaAccount.setCountry(selectedItem); TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code); setupCurrency(selectedItem, currency); updateCountriesSelection(true, euroCountryCheckBoxes); updateCountriesSelection(true, nonEuroCountryCheckBoxes); updateFromInputs(); }); addEuroCountriesGrid(true); addNonEuroCountriesGrid(true); addAllowedPeriod(); addAccountNameTextFieldWithAutoFillCheckBox(); countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllSepaCountries())); Country country = CountryUtil.getDefaultCountry(); if (CountryUtil.getAllSepaCountries().contains(country)) { countryComboBox.getSelectionModel().select(country); sepaAccount.setCountry(country); TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code); setupCurrency(country, currency); } updateFromInputs(); }
From source file:se.trixon.filebydate.ui.ProfilePanel.java
private void createUI() { //setGridLinesVisible(true); Label nameLabel = new Label(Dict.NAME.toString()); Label descLabel = new Label(Dict.DESCRIPTION.toString()); Label filePatternLabel = new Label(Dict.FILE_PATTERN.toString()); Label dateSourceLabel = new Label(Dict.DATE_SOURCE.toString()); mDatePatternLabel = new Label(Dict.DATE_PATTERN.toString()); Label operationLabel = new Label(Dict.OPERATION.toString()); Label caseBaseLabel = new Label(Dict.BASENAME.toString()); Label caseExtLabel = new Label(Dict.EXTENSION.toString()); mLinksCheckBox = new CheckBox(Dict.FOLLOW_LINKS.toString()); mRecursiveCheckBox = new CheckBox(Dict.RECURSIVE.toString()); mReplaceCheckBox = new CheckBox(Dict.REPLACE.toString()); mCaseBaseComboBox = new ComboBox<>(); mDatePatternComboBox = new ComboBox<>(); mDateSourceComboBox = new ComboBox<>(); mFilePatternComboBox = new ComboBox<>(); mOperationComboBox = new ComboBox<>(); mCaseExtComboBox = new ComboBox<>(); mNameTextField = new TextField(); mDescTextField = new TextField(); mSourceChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.SOURCE.toString(), ObjectMode.DIRECTORY, SelectionMode.SINGLE);//from w ww . ja v a2 s .c o m mDestChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.DESTINATION.toString(), ObjectMode.DIRECTORY, SelectionMode.SINGLE); mFilePatternComboBox.setEditable(true); mDatePatternComboBox.setEditable(true); //mDatePatternLabel.setPrefWidth(300); int col = 0; int row = 0; add(nameLabel, col, row, REMAINING, 1); add(mNameTextField, col, ++row, REMAINING, 1); add(descLabel, col, ++row, REMAINING, 1); add(mDescTextField, col, ++row, REMAINING, 1); add(mSourceChooserPane, col, ++row, REMAINING, 1); add(mDestChooserPane, col, ++row, REMAINING, 1); GridPane patternPane = new GridPane(); patternPane.addRow(0, filePatternLabel, dateSourceLabel, mDatePatternLabel); patternPane.addRow(1, mFilePatternComboBox, mDateSourceComboBox, mDatePatternComboBox); patternPane.setHgap(8); addRow(++row, patternPane); GridPane.setHgrow(mFilePatternComboBox, Priority.ALWAYS); GridPane.setHgrow(mDateSourceComboBox, Priority.ALWAYS); GridPane.setHgrow(mDatePatternComboBox, Priority.ALWAYS); GridPane.setFillWidth(mFilePatternComboBox, true); GridPane.setFillWidth(mDateSourceComboBox, true); GridPane.setFillWidth(mDatePatternComboBox, true); double width = 100.0 / 3.0; ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(width); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(width); ColumnConstraints col3 = new ColumnConstraints(); col3.setPercentWidth(width); patternPane.getColumnConstraints().addAll(col1, col2, col3); mFilePatternComboBox.setMaxWidth(Double.MAX_VALUE); mDateSourceComboBox.setMaxWidth(Double.MAX_VALUE); mDatePatternComboBox.setMaxWidth(Double.MAX_VALUE); GridPane subPane = new GridPane(); //subPane.setGridLinesVisible(true); subPane.addRow(0, operationLabel, new Label(), new Label(), new Label(), caseBaseLabel, caseExtLabel); subPane.addRow(1, mOperationComboBox, mLinksCheckBox, mRecursiveCheckBox, mReplaceCheckBox, mCaseBaseComboBox, mCaseExtComboBox); subPane.setHgap(8); add(subPane, col, ++row, REMAINING, 1); final Insets rowInsets = new Insets(0, 0, 8, 0); GridPane.setMargin(mNameTextField, rowInsets); GridPane.setMargin(mDescTextField, rowInsets); GridPane.setMargin(mSourceChooserPane, rowInsets); GridPane.setMargin(mDestChooserPane, rowInsets); GridPane.setMargin(patternPane, rowInsets); mFilePatternComboBox.setItems(FXCollections.observableArrayList("*", "{*.jpg,*.JPG}", "{*.mp4,*.MP4}")); mDatePatternComboBox.setItems(FXCollections.observableArrayList("yyyy/MM/yyyy-MM-dd", "yyyy/MM/yyyy-MM-dd/HH", "yyyy/MM/dd", "yyyy/ww", "yyyy/ww/u")); mCaseBaseComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values()))); mCaseExtComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values()))); mDateSourceComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(DateSource.values()))); mOperationComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Command.COPY, Command.MOVE))); }
From source file:gov.va.isaac.gui.ConceptNode.java
/** * descriptionReader is optional//from w w w . j a v a 2 s. com */ public ConceptNode(ConceptVersionBI initialConcept, boolean flagAsInvalidWhenBlank, ObservableList<SimpleDisplayConcept> dropDownOptions, Function<ConceptVersionBI, String> descriptionReader) { c_ = initialConcept; //We can't simply use the ObservableList from the CommonlyUsedConcepts, because it infinite loops - there doesn't seem to be a way //to change the items in the drop down without changing the selection. So, we have this hack instead. listChangeListener_ = new ListChangeListener<SimpleDisplayConcept>() { @Override public void onChanged(Change<? extends SimpleDisplayConcept> c) { //TODO I still have an infinite loop here. Find and fix. logger.debug("updating concept dropdown"); disableChangeListener_ = true; SimpleDisplayConcept temp = cb_.getValue(); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setValue(temp); cb_.getSelectionModel().select(temp); disableChangeListener_ = false; } }; descriptionReader_ = (descriptionReader == null ? (conceptVersion) -> { return conceptVersion == null ? "" : OTFUtility.getDescription(conceptVersion); } : descriptionReader); dropDownOptions_ = dropDownOptions == null ? AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts() : dropDownOptions; dropDownOptions_.addListener(new WeakListChangeListener<SimpleDisplayConcept>(listChangeListener_)); conceptBinding_ = new ObjectBinding<ConceptVersionBI>() { @Override protected ConceptVersionBI computeValue() { return c_; } }; flagAsInvalidWhenBlank_ = flagAsInvalidWhenBlank; cb_ = new ComboBox<>(); cb_.setConverter(new StringConverter<SimpleDisplayConcept>() { @Override public String toString(SimpleDisplayConcept object) { return object == null ? "" : object.getDescription(); } @Override public SimpleDisplayConcept fromString(String string) { return new SimpleDisplayConcept(string, 0); } }); cb_.setValue(new SimpleDisplayConcept("", 0)); cb_.setEditable(true); cb_.setMaxWidth(Double.MAX_VALUE); cb_.setPrefWidth(ComboBox.USE_COMPUTED_SIZE); cb_.setMinWidth(200.0); cb_.setPromptText("Type, drop or select a concept"); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setVisibleRowCount(11); cm_ = new ContextMenu(); MenuItem copyText = new MenuItem("Copy Description"); copyText.setGraphic(Images.COPY.createImageView()); copyText.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { CustomClipboard.set(cb_.getEditor().getText()); } }); cm_.getItems().add(copyText); CommonMenusNIdProvider nidProvider = new CommonMenusNIdProvider() { @Override public Set<Integer> getNIds() { Set<Integer> nids = new HashSet<>(); if (c_ != null) { nids.add(c_.getNid()); } return nids; } }; CommonMenuBuilderI menuBuilder = CommonMenus.CommonMenuBuilder.newInstance(); menuBuilder.setInvisibleWhenFalse(isValid); CommonMenus.addCommonMenus(cm_, menuBuilder, nidProvider); cb_.getEditor().setContextMenu(cm_); updateGUI(); new LookAheadConceptPopup(cb_); if (cb_.getValue().getNid() == 0) { if (flagAsInvalidWhenBlank_) { isValid.setInvalid("Concept Required"); } } else { isValid.setValid(); } cb_.valueProperty().addListener(new ChangeListener<SimpleDisplayConcept>() { @Override public void changed(ObservableValue<? extends SimpleDisplayConcept> observable, SimpleDisplayConcept oldValue, SimpleDisplayConcept newValue) { if (newValue == null) { logger.debug("Combo Value Changed - null entry"); } else { logger.debug("Combo Value Changed: {} {}", newValue.getDescription(), newValue.getNid()); } if (disableChangeListener_) { logger.debug("change listener disabled"); return; } if (newValue == null) { //This can happen if someone calls clearSelection() - it passes in a null. cb_.setValue(new SimpleDisplayConcept("", 0)); return; } else { if (newValue.shouldIgnoreChange()) { logger.debug("One time change ignore"); return; } //Whenever the focus leaves the combo box editor, a new combo box is generated. But, the new box will have 0 for an id. detect and ignore if (oldValue != null && oldValue.getDescription().equals(newValue.getDescription()) && newValue.getNid() == 0) { logger.debug("Not a real change, ignore"); newValue.setNid(oldValue.getNid()); return; } lookup(); } } }); AppContext.getService(DragRegistry.class).setupDragAndDrop(cb_, new SingleConceptIdProvider() { @Override public String getConceptId() { return cb_.getValue().getNid() + ""; } }, true); pi_ = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); pi_.visibleProperty().bind(isLookupInProgress_); pi_.setPrefHeight(16.0); pi_.setPrefWidth(16.0); pi_.setMaxWidth(16.0); pi_.setMaxHeight(16.0); lookupFailImage_ = Images.EXCLAMATION.createImageView(); lookupFailImage_.visibleProperty().bind(isValid.not().and(isLookupInProgress_.not())); Tooltip t = new Tooltip(); t.textProperty().bind(isValid.getReasonWhyInvalid()); Tooltip.install(lookupFailImage_, t); StackPane sp = new StackPane(); sp.setMaxWidth(Double.MAX_VALUE); sp.getChildren().add(cb_); sp.getChildren().add(lookupFailImage_); sp.getChildren().add(pi_); StackPane.setAlignment(cb_, Pos.CENTER_LEFT); StackPane.setAlignment(lookupFailImage_, Pos.CENTER_RIGHT); StackPane.setMargin(lookupFailImage_, new Insets(0.0, 30.0, 0.0, 0.0)); StackPane.setAlignment(pi_, Pos.CENTER_RIGHT); StackPane.setMargin(pi_, new Insets(0.0, 30.0, 0.0, 0.0)); hbox_ = new HBox(); hbox_.setSpacing(5.0); hbox_.setAlignment(Pos.CENTER_LEFT); hbox_.getChildren().add(sp); HBox.setHgrow(sp, Priority.SOMETIMES); }
From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java
public ColorPreferencePanel() { VBox vbox = new VBox(); GridPane colorPanel = new GridPane(); for (ColorPreferenceEntry entry : entries2) { ColorPicker colorPicker = new ColorPicker(preferences.getColorPref(entry.preferenceName)); entry.button = colorPicker;// w w w . ja va 2 s .c o m colorPanel.add(new Label(entry.preferenceName), 0, entry.row); colorPanel.add(colorPicker, 1, entry.row); } GridPane plotColorPanel = new GridPane(); int gridx = 0; int gridy = 0; // // Layout the column headers // for (int i = 0; i < COLOR_COL_HEADERS.length; i++) { gridx = i; plotColorPanel.add(new Label(COLOR_COL_HEADERS[i]), gridx, gridy); } // // Layout the row leaders // //c.anchor = GridBagConstraints.EAST; for (String header : COLOR_ROW_HEADERS) { gridx = 0; gridy++; plotColorPanel.add(new Label(header), gridx, gridy); gridx = 5; Set<String> names = ColorSchemeCollection.getColorSchemeNames(); ComboBox<String> scheme = new ComboBox<>(); scheme.getItems().addAll(names); scheme.setUserData(gridy); plotColorPanel.add(scheme, gridx, gridy); scheme.setOnAction((ActionEvent e) -> { ComboBox<String> cb = (ComboBox<String>) e.getSource(); applyColorScheme((Integer) cb.getUserData(), cb.getSelectionModel().getSelectedItem()); }); gridx = 6; CheckBox showSeries = new CheckBox(); showSeries.setUserData(gridy); plotColorPanel.add(showSeries, gridx, gridy); showSeries.setOnAction((ActionEvent e) -> { CheckBox cb = (CheckBox) e.getSource(); int row = (Integer) cb.getUserData(); for (ColorPreferenceEntry entry : entries) { if (entry.row == row) { addRemoveSeries(entry.preferenceName, cb.isSelected()); } } createSeriesData(); configureRenderer(); }); } //c.anchor = GridBagConstraints.CENTER; for (ColorPreferenceEntry entry : entries) { gridx = entry.column; gridy = entry.row; ColorPicker button = new ColorPicker(); button.setValue(preferences.getColorPref(entry.preferenceName)); //button.setPrefSize(10, 10); button.setUserData(entry); plotColorPanel.add(button, gridx, gridy); entry.button = button; } JFreeChart chart = ChartFactory.createXYLineChart("Example", "X Axis", "Y Axis", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(renderer); ChartViewer graphExamplePanel = new ChartViewer(chart); vbox.getChildren().addAll(colorPanel, plotColorPanel); setTop(vbox); setCenter(graphExamplePanel); FlowPane buttonPanel = new FlowPane(); Button button = new Button("OK"); button.setOnAction((ActionEvent e) -> { saveData(); }); buttonPanel.getChildren().add(button); setBottom(buttonPanel); }