Search in sources :

Example 1 with JFXDrawer

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

the class DrawerDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    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.setContent(content);	
    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.setContent(leftDrawer);
    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.setContent(bottomDrawer);
    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.setContent(rightDrawer);
    topDrawer.setOverLayVisible(false);
    topDrawer.setResizableOnDrag(true);
    JFXDrawersStack drawersStack = new JFXDrawersStack();
    drawersStack.setContent(content);
    leftDrawer.setId("LEFT");
    rightDrawer.setId("RIGHT");
    bottomDrawer.setId("BOT");
    topDrawer.setId("TOP");
    leftButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
        drawersStack.toggle(leftDrawer);
    });
    bottomButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
        drawersStack.toggle(bottomDrawer);
    });
    rightButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
        drawersStack.toggle(rightDrawer);
    });
    topButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
        drawersStack.toggle(topDrawer);
    });
    final Scene scene = new Scene(drawersStack, 800, 800);
    scene.getStylesheets().add(DrawerDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
    scene.getStylesheets().add(DrawerDemo.class.getResource("/resources/css/jfoenix-design.css").toExternalForm());
    primaryStage.setTitle("JFX Drawer Demo");
    primaryStage.setScene(scene);
    primaryStage.setResizable(true);
    primaryStage.show();
}
Also used : JFXDrawer(com.jfoenix.controls.JFXDrawer) FlowPane(javafx.scene.layout.FlowPane) JFXButton(com.jfoenix.controls.JFXButton) JFXDrawersStack(com.jfoenix.controls.JFXDrawersStack) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Aggregations

JFXButton (com.jfoenix.controls.JFXButton)1 JFXDrawer (com.jfoenix.controls.JFXDrawer)1 JFXDrawersStack (com.jfoenix.controls.JFXDrawersStack)1 Scene (javafx.scene.Scene)1 FlowPane (javafx.scene.layout.FlowPane)1 StackPane (javafx.scene.layout.StackPane)1