@Override public StyleableBooleanProperty getStyleableProperty(JFXRadioButton control) { return control.disableAnimationProperty(); } };
@Override public StyleableBooleanProperty getStyleableProperty(JFXRadioButton control) { return control.disableVisualFocusProperty(); } };
@Override public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Control.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); styleables.addAll(Labeled.getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }
/** * {@inheritDoc} */ public JFXRadioButton() { initialize(); // init in scene builder workaround ( TODO : remove when JFoenix is well integrated in scenebuilder by gluon ) StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); for (int i = 0; i < stackTraceElements.length && i < 15; i++) { if (stackTraceElements[i].getClassName().toLowerCase().contains(".scenebuilder.kit.fxom.")) { this.setText("RadioButton"); break; } } }
dot.fillProperty().bind(control.selectedColorProperty()); dot.setScaleX(0); dot.setScaleY(0); control.focusedProperty().addListener((o, oldVal, newVal) -> { if (!control.disableVisualFocusProperty().get()) { if (newVal) { if (!getSkinnable().isPressed()) { control.pressedProperty().addListener((o, oldVal, newVal) -> rippler.setOverlayVisible(false)); JFXKeyValue.builder() .setTarget(radio.strokeProperty()) .setEndValueSupplier(() -> getSkinnable().isSelected() ? ((JFXRadioButton) getSkinnable()).getSelectedColor() : ((JFXRadioButton) getSkinnable()).getUnSelectedColor()) .setInterpolator(Interpolator.EASE_BOTH) .build() )); registerChangeListener(control.selectedColorProperty(), "SELECTED_COLOR"); registerChangeListener(control.unSelectedColorProperty(), "UNSELECTED_COLOR"); registerChangeListener(control.selectedProperty(), "SELECTED");
@Override protected void handleControlPropertyChanged(String p) { super.handleControlPropertyChanged(p); if ("SELECTED_COLOR".equals(p)) { // update current colors updateColors(); } else if ("UNSELECTED_COLOR".equals(p)) { // update current colors updateColors(); } else if ("SELECTED".equals(p)) { // update ripple color boolean isSelected = getSkinnable().isSelected(); Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor(); Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor(); rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor); if (((JFXRadioButton) getSkinnable()).isDisableAnimation()) { // apply end values timer.applyEndValues(); } else { // play selection animation timer.reverseAndContinue(); } } }
private void updateColors() { boolean isSelected = getSkinnable().isSelected(); Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor(); Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor(); rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor); radio.setStroke(isSelected ? selectedColor : unSelectedColor); }
@Override public void start(Stage primaryStage) { final ToggleGroup group = new ToggleGroup(); JFXRadioButton javaRadio = new JFXRadioButton("JavaFX"); javaRadio.setPadding(new Insets(10)); javaRadio.setToggleGroup(group); JFXRadioButton jfxRadio = new JFXRadioButton("JFoenix"); jfxRadio.setPadding(new Insets(10)); jfxRadio.setToggleGroup(group); VBox vbox = new VBox(); vbox.getChildren().add(javaRadio); vbox.getChildren().add(jfxRadio); vbox.setSpacing(10); HBox hbox = new HBox(); hbox.getChildren().add(vbox); hbox.setSpacing(50); hbox.setPadding(new Insets(40, 10, 10, 120)); Scene scene = new Scene(hbox); primaryStage.setScene(scene); primaryStage.setWidth(500); primaryStage.setHeight(400); primaryStage.setTitle("JFX RadioButton Demo "); scene.getStylesheets() .add(RadioButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.show(); }
/** * {@inheritDoc} */ public JFXRadioButton(String text) { super(text); initialize(); }
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); }
final HBox internalLayout = new HBox(); final RadioButton button = new JFXRadioButton(); button.setToggleGroup(group); button.setText(model.getValue());
dot.fillProperty().bind(control.selectedColorProperty()); dot.setScaleX(0); dot.setScaleY(0); control.focusedProperty().addListener((o, oldVal, newVal) -> { if (!control.disableVisualFocusProperty().get()) { if (newVal) { if (!getSkinnable().isPressed()) { control.pressedProperty().addListener((o, oldVal, newVal) -> rippler.setOverlayVisible(false)); JFXKeyValue.builder() .setTarget(radio.strokeProperty()) .setEndValueSupplier(() -> getSkinnable().isSelected() ? ((JFXRadioButton) getSkinnable()).getSelectedColor() : ((JFXRadioButton) getSkinnable()).getUnSelectedColor()) .setInterpolator(Interpolator.EASE_BOTH) .build() registerChangeListener(control.selectedColorProperty(), obs -> updateColors()); registerChangeListener(control.unSelectedColorProperty(), obs -> updateColors()); registerChangeListener(control.selectedProperty(), obs -> { boolean isSelected = getSkinnable().isSelected(); Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor(); Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor(); rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor); if (((JFXRadioButton) getSkinnable()).isDisableAnimation()) {
private void updateColors() { boolean isSelected = getSkinnable().isSelected(); Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor(); Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor(); rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor); radio.setStroke(isSelected ? selectedColor : unSelectedColor); }
/** * {@inheritDoc} */ public JFXRadioButton() { initialize(); // init in scene builder workaround ( TODO : remove when JFoenix is well integrated in scenebuilder by gluon ) StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); for (int i = 0; i < stackTraceElements.length && i < 15; i++) { if (stackTraceElements[i].getClassName().toLowerCase().contains(".scenebuilder.kit.fxom.")) { this.setText("RadioButton"); break; } } }
/** * {@inheritDoc} */ public JFXRadioButton(String text) { super(text); initialize(); }
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); }
final RadioButton button = new JFXRadioButton(); button.setToggleGroup(item.preferenceItem().getToggleGroup());
public final Boolean isDisableVisualFocus() { return disableVisualFocus != null && this.disableVisualFocusProperty().get(); }
public final Boolean isDisableAnimation() { return disableAnimation != null && this.disableAnimationProperty().get(); }
@Override public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Control.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); styleables.addAll(Labeled.getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }