List of usage examples for javafx.scene.layout BorderPane BorderPane
public BorderPane()
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane bp = new BorderPane(); bp.setPadding(new Insets(10, 50, 50, 50)); Scene scene = new Scene(bp); primaryStage.setScene(scene);// w w w . j a va 2 s. c om primaryStage.titleProperty() .bind(scene.widthProperty().asString().concat(" : ").concat(scene.heightProperty().asString())); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 180, 250); String[] keys = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#" }; GridPane numPad = new GridPane(); for (int i = 0; i < 12; i++) { Button button = new Button(keys[i]); button.getStyleClass().add("num-button"); numPad.add(button, i % 3, (int) Math.ceil(i / 3)); }//ww w. ja v a 2s . c om Button call = new Button("Call"); call.setId("call-button"); call.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); numPad.add(call, 0, 4); GridPane.setColumnSpan(call, 3); GridPane.setHgrow(call, Priority.ALWAYS); root.setCenter(numPad); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane bp = new BorderPane(); bp.setPadding(new Insets(10, 20, 10, 20)); Button btnTop = new Button("Top"); bp.setTop(btnTop);//w ww .j ava2 s .c om Button btnLeft = new Button("Left"); bp.setLeft(btnLeft); Button btnCenter = new Button("Center"); bp.setCenter(btnCenter); Button btnRight = new Button("Right"); bp.setRight(btnRight); Button btnBottom = new Button("Bottom"); bp.setBottom(btnBottom); Scene scene = new Scene(bp, 300, 200); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane bp = new BorderPane(); bp.setPadding(new Insets(10, 20, 10, 20)); Button btnTop = new Button("Top"); bp.setTop(btnTop);//from w w w. j a v a 2 s. c o m Button btnLeft = new Button("Left"); bp.setLeft(btnLeft); Button btnCenter = new Button("Center"); bp.setCenter(btnCenter); Button btnRight = new Button("Right"); bp.setRight(btnRight); Button btnBottom = new Button("Bottom"); bp.setBottom(btnBottom); Scene scene = new Scene(bp, 300, 200); primaryStage.setScene(scene); primaryStage.show(); System.out.println(bp.getTop()); System.out.println(bp.getBottom()); System.out.println(bp.getLeft()); System.out.println(bp.getRight()); System.out.println(bp.getCenter()); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.setTop(menuBar);//from ww w.j a v a 2s.co m Menu fileMenu = new Menu("File"); MenuItem exitMenuItem = new MenuItem("Exit"); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setOnAction(actionEvent -> Platform.exit()); menuBar.getMenus().addAll(fileMenu); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.setTop(menuBar);/* w w w . ja v a 2 s . c om*/ Menu fileMenu = new Menu("_File"); fileMenu.setMnemonicParsing(true); MenuItem exitMenuItem = new MenuItem("Exit"); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setOnAction(actionEvent -> Platform.exit()); menuBar.getMenus().addAll(fileMenu); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("BorderPane Test"); BorderPane bp = new BorderPane(); bp.setPadding(new Insets(10, 20, 10, 20)); Button btnTop = new Button("Top"); bp.setTop(btnTop);/*from w w w.ja v a 2s . co m*/ Button btnLeft = new Button("Left"); bp.setLeft(btnLeft); Button btnCenter = new Button("Center"); bp.setCenter(btnCenter); Button btnRight = new Button("Right"); bp.setRight(btnRight); Button btnBottom = new Button("Bottom"); bp.setBottom(btnBottom); Scene scene = new Scene(bp, 300, 200); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); root.setTop(menuBar);/* ww w . j av a 2s.c om*/ // File menu - new, save, exit Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New"); MenuItem saveMenuItem = new MenuItem("Save"); MenuItem exitMenuItem = new MenuItem("Exit"); exitMenuItem.setOnAction(actionEvent -> Platform.exit()); fileMenu.getItems().addAll(newMenuItem, saveMenuItem, new SeparatorMenuItem(), exitMenuItem); Menu webMenu = new Menu("Web"); CheckMenuItem htmlMenuItem = new CheckMenuItem("HTML"); htmlMenuItem.setSelected(true); webMenu.getItems().add(htmlMenuItem); CheckMenuItem cssMenuItem = new CheckMenuItem("CSS"); cssMenuItem.setSelected(true); webMenu.getItems().add(cssMenuItem); Menu sqlMenu = new Menu("SQL"); ToggleGroup tGroup = new ToggleGroup(); RadioMenuItem mysqlItem = new RadioMenuItem("MySQL"); mysqlItem.setToggleGroup(tGroup); RadioMenuItem oracleItem = new RadioMenuItem("Oracle"); oracleItem.setToggleGroup(tGroup); oracleItem.setSelected(true); sqlMenu.getItems().addAll(mysqlItem, oracleItem, new SeparatorMenuItem()); Menu tutorialManeu = new Menu("Tutorial"); tutorialManeu.getItems().addAll(new CheckMenuItem("Java"), new CheckMenuItem("JavaFX"), new CheckMenuItem("Swing")); sqlMenu.getItems().add(tutorialManeu); menuBar.getMenus().addAll(fileMenu, webMenu, sqlMenu); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w ww . j a v a2 s . c o m*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); Label selectedLbl = new Label("selected"); gridpane.add(selectedLbl, 2, 0); GridPane.setHalignment(selectedLbl, HPos.CENTER); // Candidates final ObservableList<String> candidates = FXCollections.observableArrayList("Z", "A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> selected = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(selected); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); selected.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String s = heroListView.getSelectionModel().getSelectedItem(); if (s != null) { heroListView.getSelectionModel().clearSelection(); selected.remove(s); candidates.add(s); } }); VBox vbox = new VBox(5); vbox.getChildren().addAll(sendRightButton, sendLeftButton); gridpane.add(vbox, 1, 1); root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w ww . j av a 2 s . c o m*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); // Candidates label Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); // Heroes label Label heroesLbl = new Label("Letters"); gridpane.add(heroesLbl, 2, 0); GridPane.setHalignment(heroesLbl, HPos.CENTER); final ObservableList<String> candidates = FXCollections.observableArrayList("A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> heroes = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(heroes); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); heroes.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String notHero = heroListView.getSelectionModel().getSelectedItem(); if (notHero != null) { heroListView.getSelectionModel().clearSelection(); heroes.remove(notHero); candidates.add(notHero); } }); // place the buttons VBox vbox = new VBox(5); vbox.setAlignment(Pos.CENTER); vbox.getChildren().addAll(sendRightButton, sendLeftButton); GridPane.setHalignment(vbox, HPos.CENTER); gridpane.add(vbox, 1, 1); // place the grid root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }