Java Code Examples for com.jfoenix.controls.JFXButton#addEventHandler()

The following examples show how to use com.jfoenix.controls.JFXButton#addEventHandler() . 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: Main.java    From JFX-Browser with MIT License 6 votes vote down vote up
public static void setDialouge(JFXButton applyButton , String heading , String text , Node ob) {
	
	JFXButton button = applyButton;
	
	content.setHeading(new Text(heading));
	content.setBody(new Text(text));
	
	JFXDialog dialoge = new JFXDialog(pane, content, JFXDialog.DialogTransition.CENTER);
	button.addEventHandler(MouseEvent.MOUSE_CLICKED, (e6) -> {
		dialoge.close();
	});
	
	content.setActions(ob, button);
	
	// To show overlay dialougge box
	dialoge.show();
}
 
Example 2
Source File: HistoryController.java    From JFX-Browser with MIT License 4 votes vote down vote up
@FXML
void deleteHistory(MouseEvent event) {

	// confirmation dialogue
	/*	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.setTitle("Confirmation Dialog");
	alert.setHeaderText("History");
	alert.setContentText("Are you want to delete all History ?");
	Optional<ButtonType> result = alert.showAndWait();*/

	JFXButton okBt = new JFXButton("Ok");
	JFXButton cancelBt = new JFXButton("Cancel");

	okBt.setId("mybutton");
	cancelBt.setId("mybutton");

	JFXDialogLayout content = new JFXDialogLayout();
	content.setHeading(new Text("Clear History"));
	content.setBody(new Text(" You are going to delete your complete history. After that\n"
			+ "you will not have any single url in your history. Click Ok \n"
			+ "to confirm or click cancel to main window."));
	JFXDialog historyWarn= new JFXDialog(Main.getPane(),content,JFXDialog.DialogTransition.CENTER);
	content.setActions(okBt,cancelBt);
	historyWarn.show();	

	okBt.addEventHandler(MouseEvent.MOUSE_CLICKED, (e6) -> {

		historyWarn.close();

		JFXButton yesBt = new JFXButton("Yes");
		JFXButton noBt = new JFXButton("No");

		JFXDialogLayout confirmContent = new JFXDialogLayout();
		confirmContent.setHeading(new Text("Clear History"));
		confirmContent.setBody(new Text("Do you want to delete your complete history?"));
		JFXDialog historyConfirm = new JFXDialog(Main.getPane(), confirmContent, JFXDialog.DialogTransition.CENTER);
		confirmContent.setActions(yesBt, noBt);
		historyConfirm.show();

		yesBt.addEventHandler(MouseEvent.MOUSE_CLICKED, (e7) -> {

			table.setRoot(null);
			table.refresh();
			fullHistory.clear();
			pastHours.clear();
			pastMonthHistory.clear();
			pastWeekHistory.clear();
			yesterdayHistory.clear();
			todayHistory.clear();
			historyConfirm.close();

			HistoryManagment.deleteFromDatabase();

		});

		noBt.addEventHandler(MouseEvent.MOUSE_CLICKED, (e7) -> {
			historyConfirm.close();
		});

	});
	cancelBt.addEventHandler(MouseEvent.MOUSE_CLICKED, (e6) -> {
		historyWarn.close();
	});


	//To show overlay dialougge box

	/*
	if (alert.getResult() == ButtonType.OK) {


		// information dialogue
		alert = new Alert(AlertType.INFORMATION);
		alert.setTitle("History");
		alert.setHeaderText(null);
		String s = "History has been deleted!";
		alert.setContentText(s);
		alert.show();
	}*/


}
 
Example 3
Source File: DrawerDemo.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    FlowPane content = new FlowPane();
    JFXButton leftButton = new JFXButton(LEFT);
    JFXButton topButton = new JFXButton(TOP);
    JFXButton rightButton = new JFXButton(RIGHT);
    JFXButton bottomButton = new JFXButton(BOTTOM);
    content.getChildren().addAll(leftButton, topButton, rightButton, bottomButton);
    content.setMaxSize(200, 200);


    JFXDrawer leftDrawer = new JFXDrawer();
    StackPane leftDrawerPane = new StackPane();
    leftDrawerPane.getStyleClass().add("red-400");
    leftDrawerPane.getChildren().add(new JFXButton("Left Content"));
    leftDrawer.setSidePane(leftDrawerPane);
    leftDrawer.setDefaultDrawerSize(150);
    leftDrawer.setResizeContent(true);
    leftDrawer.setOverLayVisible(false);
    leftDrawer.setResizableOnDrag(true);


    JFXDrawer bottomDrawer = new JFXDrawer();
    StackPane bottomDrawerPane = new StackPane();
    bottomDrawerPane.getStyleClass().add("deep-purple-400");
    bottomDrawerPane.getChildren().add(new JFXButton("Bottom Content"));
    bottomDrawer.setDefaultDrawerSize(150);
    bottomDrawer.setDirection(DrawerDirection.BOTTOM);
    bottomDrawer.setSidePane(bottomDrawerPane);
    bottomDrawer.setResizeContent(true);
    bottomDrawer.setOverLayVisible(false);
    bottomDrawer.setResizableOnDrag(true);


    JFXDrawer rightDrawer = new JFXDrawer();
    StackPane rightDrawerPane = new StackPane();
    rightDrawerPane.getStyleClass().add("blue-400");
    rightDrawerPane.getChildren().add(new JFXButton("Right Content"));
    rightDrawer.setDirection(DrawerDirection.RIGHT);
    rightDrawer.setDefaultDrawerSize(150);
    rightDrawer.setSidePane(rightDrawerPane);
    rightDrawer.setOverLayVisible(false);
    rightDrawer.setResizableOnDrag(true);


    JFXDrawer topDrawer = new JFXDrawer();
    StackPane topDrawerPane = new StackPane();
    topDrawerPane.getStyleClass().add("green-400");
    topDrawerPane.getChildren().add(new JFXButton("Top Content"));
    topDrawer.setDirection(DrawerDirection.TOP);
    topDrawer.setDefaultDrawerSize(150);
    topDrawer.setSidePane(topDrawerPane);
    topDrawer.setOverLayVisible(false);
    topDrawer.setResizableOnDrag(true);


    JFXDrawersStack drawersStack = new JFXDrawersStack();
    drawersStack.setContent(content);

    leftDrawer.setId(LEFT);
    rightDrawer.setId(RIGHT);
    bottomDrawer.setId(BOTTOM);
    topDrawer.setId(TOP);

    leftButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(leftDrawer));
    bottomButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(bottomDrawer));
    rightButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(rightDrawer));
    topButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(topDrawer));


    final Scene scene = new Scene(drawersStack, 800, 800);
    final ObservableList<String> stylesheets = scene.getStylesheets();
    stylesheets.addAll(DrawerDemo.class.getResource("/css/jfoenix-components.css").toExternalForm(),
                       DrawerDemo.class.getResource("/css/jfoenix-design.css").toExternalForm());

    stage.setTitle("JFX Drawer Demo");
    stage.setScene(scene);
    stage.setResizable(true);
    stage.show();
}
 
Example 4
Source File: JFXButtonSkin.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public JFXButtonSkin(JFXButton button) {
        super(button);

        buttonRippler = new JFXRippler(getSkinnable()) {
            @Override
            protected Node getMask() {
                StackPane mask = new StackPane();
                mask.shapeProperty().bind(getSkinnable().shapeProperty());
                JFXNodeUtils.updateBackground(getSkinnable().getBackground(), mask);
                mask.resize(getWidth() - snappedRightInset() - snappedLeftInset(),
                    getHeight() - snappedBottomInset() - snappedTopInset());
                return mask;
            }

            @Override
            protected void positionControl(Node control) {
                // do nothing as the controls is not inside the ripple
            }
        };

        // add listeners to the button and bind properties
        button.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> playClickAnimation(1));
//        button.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> playClickAnimation(-1));
        button.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> mousePressed = true);
        button.addEventFilter(MouseEvent.MOUSE_RELEASED, e -> mousePressed = false);
        button.addEventFilter(MouseEvent.MOUSE_DRAGGED, e -> mousePressed = false);

        button.ripplerFillProperty().addListener((o, oldVal, newVal) -> buttonRippler.setRipplerFill(newVal));

        button.armedProperty().addListener((o, oldVal, newVal) -> {
            if (newVal) {
                if (!mousePressed) {
                    releaseManualRippler = buttonRippler.createManualRipple();
                    playClickAnimation(1);
                }
            } else {
                if (releaseManualRippler != null) {
                    releaseManualRippler.run();
                    releaseManualRippler = null;
                }
                playClickAnimation(-1);
            }
        });

        // show focused state
        button.focusedProperty().addListener((o, oldVal, newVal) -> {
            if (!button.disableVisualFocusProperty().get()) {
                if (newVal) {
                    if (!getSkinnable().isPressed()) {
                        buttonRippler.setOverlayVisible(true);
                    }
                } else {
                    buttonRippler.setOverlayVisible(false);
                }
            }
        });

        button.buttonTypeProperty().addListener((o, oldVal, newVal) -> updateButtonType(newVal));

        updateButtonType(button.getButtonType());

        updateChildren();
    }