Java Code Examples for javafx.scene.control.CheckBox#setStyle()
The following examples show how to use
javafx.scene.control.CheckBox#setStyle() .
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: DisplayWindow.java From marathonv5 with Apache License 2.0 | 6 votes |
private Node getMessageBar(VBox vbox) { HBox hb = new HBox(10); hb.setPrefHeight(32); hb.setStyle("-fx-padding: 0 5px 0 5px; -fx-background-color: " + Version._message_bg + ";"); CheckBox cb = new CheckBox("Do Not Show Again"); cb.setStyle("-fx-text-fill: " + Version._message_fg + ";-fx-fill: " + Version._message_fg + ";"); Text b = FXUIUtils.getIconAsText("close"); b.setOnMouseClicked((e) -> { JSONObject preferences = Preferences.instance().getSection("display"); preferences.put("_doNotShowMessage", cb.isSelected()); Preferences.instance().save("display"); vbox.getChildren().remove(0); }); Text t = new Text(Version._message); hb.setAlignment(Pos.CENTER_LEFT); HBox.setHgrow(t, Priority.ALWAYS); t.setStyle("-fx-fill: " + Version._message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold; -fx-font-family: Tahoma;"); b.setStyle("-fx-fill: " + Version._message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold;"); Region spacer = new Region(); HBox.setHgrow(spacer, Priority.ALWAYS); hb.getChildren().addAll(t, spacer, b); return hb; }
Example 2
Source File: MultipleAxesLineChart.java From chart-fx with Apache License 2.0 | 5 votes |
public Node getLegend() { final HBox hBox = new HBox(); final CheckBox baseChartCheckBox = new CheckBox(baseChart.getYAxis().getLabel()); baseChartCheckBox.setSelected(true); baseChartCheckBox .setStyle("-fx-text-fill: " + toRGBCode(chartColorMap.get(baseChart)) + "; -fx-font-weight: bold;"); baseChartCheckBox.setDisable(true); baseChartCheckBox.getStyleClass().add("readonly-checkbox"); baseChartCheckBox.setOnAction(event -> baseChartCheckBox.setSelected(true)); hBox.getChildren().add(baseChartCheckBox); for (final LineChart<?, ?> lineChart : backgroundCharts) { final CheckBox checkBox = new CheckBox(lineChart.getYAxis().getLabel()); checkBox.setStyle("-fx-text-fill: " + toRGBCode(chartColorMap.get(lineChart)) + "; -fx-font-weight: bold"); checkBox.setSelected(true); checkBox.setOnAction(event -> { if (backgroundCharts.contains(lineChart)) { backgroundCharts.remove(lineChart); } else { backgroundCharts.add(lineChart); } }); hBox.getChildren().add(checkBox); } hBox.setAlignment(Pos.CENTER); hBox.setSpacing(20); hBox.setStyle("-fx-padding: 0 10 20 10"); return hBox; }
Example 3
Source File: OverrideBehaviorDemo.java From RichTextFX with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void start(Stage primaryStage) { InlineCssTextArea area = new InlineCssTextArea(); InputMap<Event> preventSelectionOrRightArrowNavigation = InputMap.consume( anyOf( // prevent selection via (CTRL + ) SHIFT + [LEFT, UP, DOWN] keyPressed(LEFT, SHIFT_DOWN, SHORTCUT_ANY), keyPressed(KP_LEFT, SHIFT_DOWN, SHORTCUT_ANY), keyPressed(UP, SHIFT_DOWN, SHORTCUT_ANY), keyPressed(KP_UP, SHIFT_DOWN, SHORTCUT_ANY), keyPressed(DOWN, SHIFT_DOWN, SHORTCUT_ANY), keyPressed(KP_DOWN, SHIFT_DOWN, SHORTCUT_ANY), // prevent selection via mouse events eventType(MouseEvent.MOUSE_DRAGGED), eventType(MouseEvent.DRAG_DETECTED), mousePressed().unless(e -> e.getClickCount() == 1 && !e.isShiftDown()), // prevent any right arrow movement, regardless of modifiers keyPressed(RIGHT, SHORTCUT_ANY, SHIFT_ANY), keyPressed(KP_RIGHT, SHORTCUT_ANY, SHIFT_ANY) ) ); Nodes.addInputMap(area, preventSelectionOrRightArrowNavigation); area.replaceText(String.join("\n", "You can't move the caret to the right via the RIGHT arrow key in this area.", "Additionally, you cannot select anything either", "", ":-p" )); area.moveTo(0); CheckBox addExtraEnterHandlerCheckBox = new CheckBox("Temporarily add an EventHandler to area's `onKeyPressedProperty`?"); addExtraEnterHandlerCheckBox.setStyle("-fx-font-weight: bold;"); Label checkBoxExplanation = new Label(String.join("\n", "The added handler will insert a newline character at the caret's position when [Enter] is pressed.", "If checked, the default behavior and added handler will both occur: ", "\tthus, two newline characters should be inserted when user presses [Enter].", "When unchecked, the handler will be removed." )); checkBoxExplanation.setWrapText(true); EventHandler<KeyEvent> insertNewlineChar = e -> { if (e.getCode().equals(ENTER)) { area.insertText(area.getCaretPosition(), "\n"); e.consume(); } }; addExtraEnterHandlerCheckBox.selectedProperty().addListener( (obs, ov, isSelected) -> area.setOnKeyPressed( isSelected ? insertNewlineChar : null) ); VBox vbox = new VBox(area, addExtraEnterHandlerCheckBox, checkBoxExplanation); vbox.setSpacing(10); vbox.setPadding(new Insets(10)); primaryStage.setScene(new Scene(vbox, 700, 350)); primaryStage.show(); primaryStage.setTitle("An area whose behavior has been overridden permanently and temporarily!"); }