List of usage examples for javafx.scene.control CheckBox setUserData
public void setUserData(Object value)
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 ww.j av a2s .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); }
From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java
private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) { Label label = addLabel(gridPane, ++gridRow, title, 0); label.setWrapText(true);//from ww w.j a va 2 s .c o m label.setMaxWidth(180); label.setTextAlignment(TextAlignment.RIGHT); GridPane.setHalignment(label, HPos.RIGHT); GridPane.setValignment(label, VPos.TOP); FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(10); flowPane.setHgap(10); flowPane.setMinHeight(55); if (isEditable) flowPane.setId("flow-pane-checkboxes-bg"); else flowPane.setId("flow-pane-checkboxes-non-editable-bg"); dataProvider.stream().forEach(country -> { final String countryCode = country.code; CheckBox checkBox = new CheckBox(countryCode); checkBox.setUserData(countryCode); checkBoxList.add(checkBox); checkBox.setMouseTransparent(!isEditable); checkBox.setMinWidth(45); checkBox.setMaxWidth(45); checkBox.setTooltip(new Tooltip(country.name)); checkBox.setOnAction(event -> { if (checkBox.isSelected()) sepaAccount.addAcceptedCountry(countryCode); else sepaAccount.removeAcceptedCountry(countryCode); updateAllInputsValid(); }); flowPane.getChildren().add(checkBox); }); updateCountriesSelection(isEditable, checkBoxList); GridPane.setRowIndex(flowPane, gridRow); GridPane.setColumnIndex(flowPane, 1); gridPane.getChildren().add(flowPane); }