Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); VBox vbox = new VBox(new Text("Hi"), new Button("Ok.")); vbox.setAlignment(Pos.CENTER); vbox.setPadding(new Insets(15)); dialogStage.setScene(new Scene(vbox)); dialogStage.show();
@Override public void start(final Stage stage) throws Exception { StackPane pane = new StackPane(); JFXSpinner root = new JFXSpinner(); pane.getChildren().add(root); final Scene scene = new Scene(pane, 300, 300); scene.getStylesheets().add(MainDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setTitle("JFX Spinner Demo"); stage.show(); }
Stage stage = new Stage(); try { stage.setScene(new Scene(fxmlLoader.load())); } catch (IOException e) { e.printStackTrace(); stage.setTitle("Auxilliary classpath setup"); stage.initOwner(parentStage); stage.initModality(Modality.WINDOW_MODAL); stage.close(); onApply.accept(fileListView.getItems()); }); cancelButton.setOnAction(e -> stage.close()); stage.show();
Stage dialog = new Stage(); // populate dialog with controls. ... dialog.initOwner(parentStage); dialog.initModality(Modality.ApplicationModal); dialog.showAndWait(); // process result of dialog operation. ...
private void clickShow(ActionEvent event) { Stage stage = new Stage(); Parent root = FXMLLoader.load( YourClassController.class.getResource("YourClass.fxml")); stage.setScene(new Scene(root)); stage.setTitle("My modal window"); stage.initModality(Modality.WINDOW_MODAL); stage.initOwner( ((Node)event.getSource()).getScene().getWindow() ); stage.show(); }
stage.setTitle("Table View Sample"); stage.setWidth(450); stage.setHeight(500); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); table.getColumns().addAll(firstNameCol, lastNameCol, emailCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(label, table); stage.setScene(new Scene(new Group(vbox))); stage.show();
stage.setTitle("Table View Sample"); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); final Label actionTaken = new Label(); return new TableCell<Person, Person>() { final ImageView buttonGraphic = new ImageView(); final Button button = new Button(); { button.setGraphic(buttonGraphic); button.setMinWidth(130); table.getColumns().addAll(firstNameCol, lastNameCol, emailCol, btnCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 10, 10, 10)); vbox.getChildren().addAll(label, table, actionTaken); VBox.setVgrow(table, Priority.ALWAYS); stage.setScene(new Scene(vbox)); stage.show();
stage.setTitle("Validation Demo"); BorderPane borderPane = new BorderPane(); scene.getStylesheets().add( ValidationDemo.class.getResource("context.css") .toExternalForm()); stage.setScene(scene); stage.show(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); grid.add(scenetitle, 0, 0, 2, 1); Label userName = new Label("User Name:"); grid.add(userName, 0, 1); grid.add(userTextField, 1, 1); Label pw = new Label("Password:"); grid.add(pw, 0, 2); grid.add(pwBox, 1, 2); btn.setOnAction(new EventHandler<ActionEvent>() {
public void start(Stage primaryStage) { HBox hbox = new HBox(10); TextField field = new TextField(); HBox.setHgrow(field, Priority.ALWAYS); hbox.setAlignment(Pos.BASELINE_LEFT); hbox.getChildren().addAll( new Label("Search:"), field, new Button("Go") ); hbox.setPadding(new Insets(10)); Scene scene = new Scene(hbox, 600, 250, Color.WHITE); primaryStage.setScene(scene); primaryStage.show(); }
public void start(Stage primaryStage) { final AtomicLong counter = new AtomicLong(-1); final Label label = new Label(); final Thread countThread = new Thread(new Runnable() { @Override countThread.start(); VBox root = new VBox(); root.getChildren().add(label); root.setPadding(new Insets(5)); root.setAlignment(Pos.CENTER); primaryStage.setScene(scene); primaryStage.show();
final Label lblTool = new Label(); HBox hBox = new HBox(); hBox.setSpacing(5.0); hBox.setPadding(new Insets(5, 5, 5, 5)); hBox.getChildren().add(lblTool); lblTool.setText(newValue.getTool()); pane.setTop(hBox); pane.setCenter(table); stage.setScene(new Scene(pane, 640, 480)); stage.show();
@Override public void start(Stage primaryStage) { HBox hbox = new HBox(); Button b = new Button("add"); b.setOnAction(ev -> hbox.getChildren().add(new Label("Test"))); ScrollPane scrollPane = new ScrollPane(hbox); scrollPane.setFitToHeight(true); BorderPane root = new BorderPane(scrollPane); root.setPadding(new Insets(15)); root.setTop(b); Scene scene = new Scene(root, 400, 400); primaryStage.setScene(scene); primaryStage.show(); }
Label menuLabel = new Label("File"); // menuLabel.setStyle("-fx-background-color: yellow; -fx-padding: 0px;"); menuLabel.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { System.out.println("File menu clicked"); Stage myDialog = new Stage(); myDialog.initModality(Modality.WINDOW_MODAL); Scene myDialogScene = new Scene(VBoxBuilder.create() .children(new Text("Hello! it's My Dialog.")) .alignment(Pos.CENTER) .padding(new Insets(10)) .build()); myDialog.setScene(myDialogScene); myDialog.show(); } }); Menu fileMenuButton = new Menu(); fileMenuButton.setGraphic(menuLabel); menuBar.getMenus().add(fileMenuButton);
Button startButton = new Button("Start"); startButton.setOnAction(event -> { MessageProducer producer = new MessageProducer(messageQueue); Thread t = new Thread(producer); controls.setPadding(new Insets(10)); controls.setAlignment(Pos.CENTER); primaryStage.setScene(scene); primaryStage.show();
Button button = new Button("Go!"); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { task.playFromStart(); VBox layout = new VBox(10); layout.getChildren().setAll( bar, button ); layout.setPadding(new Insets(10)); layout.setAlignment(Pos.CENTER); ); stage.setScene(new Scene(layout)); stage.show();
public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Label label = new Label("Some\ntext"); label.setGraphic(new ImageView(getClass().getResource("/images/Folder-icon.png").toExternalForm())); label.setMaxWidth(Double.POSITIVE_INFINITY); label.setMaxHeight(Double.POSITIVE_INFINITY); label.setStyle("-fx-border-color: blue;"); ctrls.setHgap(5); ctrls.setVgap(5); ctrls.setPadding(new Insets(10)); ctrls.addRow(0, new Label("Content display:"), new Label("Alignment:"), new Label("Text Alignment:")); primaryStage.setScene(scene); primaryStage.show();
private static final Insets SAFETY_ZONE = new Insets(10); private Label cowerInFear = new Label(); private Stage mainStage; cowerInFear.setText("The Wumpus " + nextAttack() + "!"); mainStage.sizeToScene(); mainStage.show(); });
stage.setTitle("Spacing demo"); Button btnSave = new Button("Save"); Button btnDelete = new Button("Delete"); HBox hBox = HBoxBuilder.create() .spacing(30.0) //In case you are using HBoxBuilder .padding(new Insets(5, 5, 5, 5)) .children(btnSave, btnDelete) .build(); stage.setScene(new Scene(hBox, 320, 240)); stage.show();
public void start(Stage stage) throws IOException { Button button = new Button("Click Me!"); button.setOnAction(event -> { nClicks++; System.out.println("Clicked " + nClicks + " times."); }); button.setPadding(new Insets(10)); button.setPrefWidth(100); stage.setScene(new Scene(button)); stage.show();