Search in sources :

Example 1 with JFXToggleNode

use of com.jfoenix.controls.JFXToggleNode in project JFoenix by jfoenixadmin.

the class ToggleButtonDemo method start.

@Override
public void start(Stage stage) throws Exception {
    final VBox pane = new VBox();
    pane.setSpacing(30);
    pane.setStyle("-fx-background-color:#EEE; -fx-padding: 40;");
    ToggleButton button = new ToggleButton("JavaFx Toggle");
    pane.getChildren().add(button);
    JFXToggleButton toggleButton = new JFXToggleButton();
    toggleButton.setText("New Skin");
    pane.getChildren().add(toggleButton);
    JFXToggleNode node = new JFXToggleNode();
    node.setStyle("-fx-padding: 10");
    node.setGraphic(new FontIcon(FontAwesomeSolid.HEART));
    pane.getChildren().add(node);
    final Scene scene = new Scene(pane, 600, 400, Color.valueOf("#EEE"));
    stage.setTitle("JFX Toggle Button Demo ");
    scene.getStylesheets().add(ToggleButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();
}
Also used : ToggleButton(javafx.scene.control.ToggleButton) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) JFXToggleNode(com.jfoenix.controls.JFXToggleNode) FontIcon(org.kordamp.ikonli.javafx.FontIcon) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 2 with JFXToggleNode

use of com.jfoenix.controls.JFXToggleNode in project JFoenix by jfoenixadmin.

the class JFXToggleNodeSkin method updateSelectionBackground.

public void updateSelectionBackground() {
    CornerRadii radii = getSkinnable().getBackground() == null ? CornerRadii.EMPTY : getSkinnable().getBackground().getFills().get(0).getRadii();
    Insets insets = getSkinnable().getBackground() == null ? Insets.EMPTY : getSkinnable().getBackground().getFills().get(0).getInsets();
    selectionOverLay.setBackground(new Background(new BackgroundFill(getSkinnable().isSelected() ? ((JFXToggleNode) getSkinnable()).getSelectedColor() : ((JFXToggleNode) getSkinnable()).getUnSelectedColor(), radii, insets)));
}
Also used : JFXToggleNode(com.jfoenix.controls.JFXToggleNode) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) CornerRadii(javafx.scene.layout.CornerRadii)

Aggregations

JFXToggleNode (com.jfoenix.controls.JFXToggleNode)2 JFXToggleButton (com.jfoenix.controls.JFXToggleButton)1 Insets (javafx.geometry.Insets)1 Scene (javafx.scene.Scene)1 ToggleButton (javafx.scene.control.ToggleButton)1 Background (javafx.scene.layout.Background)1 BackgroundFill (javafx.scene.layout.BackgroundFill)1 CornerRadii (javafx.scene.layout.CornerRadii)1 VBox (javafx.scene.layout.VBox)1 FontIcon (org.kordamp.ikonli.javafx.FontIcon)1