Search in sources :

Example 1 with SnackbarEvent

use of com.jfoenix.controls.JFXSnackbar.SnackbarEvent in project JFoenix by jfoenixadmin.

the class IconsController method init.

@PostConstruct
public void init() throws FlowException, VetoException {
    bindAction(burger1);
    bindAction(burger2);
    bindAction(burger3);
    bindAction(burger4);
    snackbar.registerSnackbarContainer(root);
    badge1.setOnMouseClicked((e) -> {
        int value = Integer.parseInt(badge1.getText());
        if (e.getButton() == MouseButton.PRIMARY) {
            value++;
        } else if (e.getButton() == MouseButton.SECONDARY) {
            value--;
        }
        if (value == 0) {
            badge1.setEnabled(false);
        } else {
            badge1.setEnabled(true);
        }
        badge1.setText(String.valueOf(value));
        // trigger snackbar
        if (count++ % 2 == 0) {
            snackbar.fireEvent(new SnackbarEvent("Toast Message " + count));
        } else {
            if (count % 4 == 0) {
                snackbar.fireEvent(new SnackbarEvent("Snackbar Message Persistant " + count, "CLOSE", 3000, true, (b) -> {
                    snackbar.close();
                }));
            } else {
                snackbar.fireEvent(new SnackbarEvent("Snackbar Message " + count, "UNDO", 3000, false, (b) -> {
                }));
            }
        }
    });
}
Also used : JFXSnackbar(com.jfoenix.controls.JFXSnackbar) VetoException(io.datafx.controller.util.VetoException) FXML(javafx.fxml.FXML) MouseButton(javafx.scene.input.MouseButton) JFXBadge(com.jfoenix.controls.JFXBadge) FlowException(io.datafx.controller.flow.FlowException) SnackbarEvent(com.jfoenix.controls.JFXSnackbar.SnackbarEvent) PostConstruct(javax.annotation.PostConstruct) StackPane(javafx.scene.layout.StackPane) FXMLController(io.datafx.controller.FXMLController) JFXHamburger(com.jfoenix.controls.JFXHamburger) SnackbarEvent(com.jfoenix.controls.JFXSnackbar.SnackbarEvent) PostConstruct(javax.annotation.PostConstruct)

Aggregations

JFXBadge (com.jfoenix.controls.JFXBadge)1 JFXHamburger (com.jfoenix.controls.JFXHamburger)1 JFXSnackbar (com.jfoenix.controls.JFXSnackbar)1 SnackbarEvent (com.jfoenix.controls.JFXSnackbar.SnackbarEvent)1 FXMLController (io.datafx.controller.FXMLController)1 FlowException (io.datafx.controller.flow.FlowException)1 VetoException (io.datafx.controller.util.VetoException)1 FXML (javafx.fxml.FXML)1 MouseButton (javafx.scene.input.MouseButton)1 StackPane (javafx.scene.layout.StackPane)1 PostConstruct (javax.annotation.PostConstruct)1