List of usage examples for javafx.scene.layout HBox getChildren
@Override
public ObservableList<Node> getChildren()
From source file:Main.java
private static HBox createHBox(final double spacing, final Node... children) { final HBox hbox = new HBox(spacing); hbox.getChildren().addAll(children); return hbox;//from w w w . j av a 2 s .c om }
From source file:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java
/** * Handles an exception that caused program startup to fail, by showing an error message to the user. * /*w w w .ja va 2 s . c o m*/ * @param title * title for the dialog * @param errorMessage * error message * @param stage * stage in which to show the error message * @param exception * exception that caused the error */ public static void show(String title, String errorMessage, final Stage stage, Exception exception) { log.info("Showing error message dialog to indicate that startup failed."); // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure. stage.setTitle(title); // Error message text. Text text = new Text(errorMessage); // Text area containing the stack trace. Not visible by default. String stackTrace; if (exception != null) { stackTrace = ExceptionUtils.getStackTrace(exception); } else { stackTrace = "No more details available."; } final TextArea stackTraceArea = new TextArea(stackTrace); stackTraceArea.setEditable(false); stackTraceArea.setVisible(false); // Details button for displaying the stack trace. Button detailsButton = new Button(); detailsButton.setText("Details"); detailsButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked Details."); stackTraceArea.setVisible(!stackTraceArea.isVisible()); } }); // OK button for closing the dialog. Button okButton = new Button(); okButton.setText("OK"); okButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked OK, closing the dialog."); stage.close(); } }); // Horizontal box containing the buttons, to make sure they are always centered. HBox buttonsBox = new HBox(5); buttonsBox.getChildren().add(detailsButton); buttonsBox.getChildren().add(okButton); buttonsBox.setAlignment(Pos.CENTER); // Layout constraints. AnchorPane.setTopAnchor(text, Double.valueOf(5)); AnchorPane.setLeftAnchor(text, Double.valueOf(5)); AnchorPane.setRightAnchor(text, Double.valueOf(5)); AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31)); AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36)); AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5)); AnchorPane root = new AnchorPane(); root.getChildren().addAll(text, stackTraceArea, buttonsBox); stage.setScene(new Scene(root)); // Use a standard program icon if possible. try { stage.getIcons().add(Icons.get().getRandomPortrait()); } catch (IllegalStateException e) { log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e); } stage.show(); // Default size should also be the minimum size. stage.setMinWidth(stage.getWidth()); stage.setMinHeight(stage.getHeight()); log.info("Error dialog displayed."); }
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Useful when taking a node already placed by a fxml file, for example, and wrapping it * in a stack pane// w w w .j a v a2s . co m * WARNING - the mechanism of moving the properties isn't currently very smart - it should only target * HBox properties, but it takes everything. * @return replacementNode */ public static StackPane swapHBoxComponents(Node placedNode, StackPane replacementNode, HBox hb) { int index = hb.getChildren().indexOf(placedNode); if (index < 0) { throw new RuntimeException("Placed Node is not in the vbox"); } hb.getChildren().remove(index); hb.getChildren().add(index, replacementNode); //this transfers the node specific constraints replacementNode.getProperties().putAll(placedNode.getProperties()); return replacementNode; }
From source file:RemoveDuplicateFiles.java
public static Scene makeScene() { //Setup the main BorderPane (Holds all the things) BorderPane backPane = new BorderPane(); //---------------------------------------------------------------------- //Setup the Main Menu Buttons & Pane sortFilesButton = new Button("Sort Files"); batchRenameButton = new Button("Batch Rename Files"); HBox mainButtons = new HBox(); mainButtons.setPadding(new Insets(15, 12, 15, 12)); mainButtons.setSpacing(10);// ww w . ja v a 2s . com mainButtons.setStyle(BUTTON_STYLE); mainButtons.getChildren().add(sortFilesButton); mainButtons.getChildren().add(batchRenameButton); backPane.setTop(mainButtons); //---------------------------------------------------------------------- //Setup the filetypes box HBox fileTypePane = GUIFactories.getFileTypeBox(fileTypes); backPane.setBottom(fileTypePane); //---------------------------------------------------------------------- //Setup the FileType Pre-set Buttons VBox preSets = GUIFactories.getPresets(fileTypes); backPane.setRight(preSets); //---------------------------------------------------------------------- //Setup the center GridPane rmvButton = new Button("Remove Duplicates"); actionTarget = new Text(); GridPane grid = GUIFactories.getCenterPane(address, rmvButton, actionTarget); backPane.setCenter(grid); //---------------------------------------------------------------------- Scene scene = new Scene(backPane, WIDTH, HEIGHT); return scene; }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private static void addNights(final HBox content, final BookingBean be) { final Text label = new Text(be.getNumberOfNights() + " nights"); content.getChildren().add(label); // HBox.setHgrow(label, Priority.SOMETIMES); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private static void addName(final HBox content, final BookingBean be) { final Label label = new Label(be.getGuest().getName() + "\n" + be.getBookingOrigin().getName()); label.setWrapText(true);//from w w w . j a v a 2 s. c o m content.getChildren().add(label); HBox.setHgrow(label, Priority.ALWAYS); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private static void addDates(final HBox content, final BookingBean be) { final TextFlow checkIn = LocalDates.getDateText(be.getCheckIn()); final TextFlow checkOut = LocalDates.getDateText(be.getCheckOut()); final TextFlow year = LocalDates.getYearText(be.getCheckOut()); final TextFlow tf = new TextFlow(); tf.getChildren().addAll(checkIn, new Text("\n"), checkOut, new Text("\n"), year); // tf.getChildren().addAll(checkIn, new Text(" "), checkOut); // HBox.setHgrow(tf, Priority.SOMETIMES); content.getChildren().add(tf); }
From source file:Main.java
@Override public void start(Stage stage) { Button b1 = new Button("B1"); Button b2 = new Button("B2"); Button b3 = new Button("B3"); Button visibleBtn = new Button("Make Invisible"); visibleBtn.setOnAction(e -> b2.setVisible(!b2.isVisible())); visibleBtn.textProperty().bind(new When(b2.visibleProperty()).then("Invisible").otherwise("Visible")); b2.managedProperty().bind(b2.visibleProperty()); HBox root = new HBox(); root.getChildren().addAll(visibleBtn, b1, b2, b3); Scene scene = new Scene(root); stage.setScene(scene);//from w w w.ja v a 2s. c om stage.setTitle(""); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Checkbox Sample"); stage.setWidth(230);/*w ww . j a va 2 s .c o m*/ stage.setHeight(120); Path path = new Path(); path.getElements().add(new MoveTo(0.0f, 50.0f)); path.getElements().add(new LineTo(100.0f, 100.0f)); VBox vbox = new VBox(); vbox.getChildren().addAll(path); vbox.setSpacing(5); HBox root = new HBox(); root.getChildren().add(vbox); root.setSpacing(40); root.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(root); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle(""); stage.setWidth(230);/* www . j ava 2s. c o m*/ stage.setHeight(120); Path path = new Path(); path.getElements().add(new MoveTo(0.0f, 50.0f)); path.getElements().add(new LineTo(100.0f, 100.0f)); VBox vbox = new VBox(); vbox.getChildren().addAll(path); vbox.setSpacing(5); HBox root = new HBox(); root.getChildren().add(vbox); root.setSpacing(40); root.setPadding(new Insets(20, 10, 10, 20)); ((Group) scene.getRoot()).getChildren().add(root); stage.setScene(scene); stage.show(); }