Example usage for javafx.scene.layout GridPane add

List of usage examples for javafx.scene.layout GridPane add

Introduction

In this page you can find the example usage for javafx.scene.layout GridPane add.

Prototype

public void add(Node child, int columnIndex, int rowIndex) 

Source Link

Document

Adds a child to the gridpane at the specified column,row position.

Usage

From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java

public static void showFatalException(final String title, final String message, final Throwable exception) {
    final Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Error");
    alert.setHeaderText(title);//from ww w .  ja  v  a 2  s  .  c o m
    alert.setContentText(message);

    final Label label = new Label("Details:");

    final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    final GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}

From source file:org.blockedit.utils.ExceptionDialog.java

/**
 * Create a exception alert that is displayed to the user.
 *
 * @param message The message to show the user
 * @param title The title of the window/*from www  . ja  va  2  s  . c  o  m*/
 * @param header The message header
 * @param exception The exception that triggered this window to be displayed to the user
 * @return A created alert
 */
private static Alert createDialog(String message, String title, String header, Exception exception) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(message);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    String exceptionText = ExceptionUtils.getStackTrace(exception);
    exception.printStackTrace();
    Label label = new Label("The exception stacktrace was:");
    TextArea exceptionArea = new TextArea(
            exceptionText + "\n\n==User Information==\njava.version = " + System.getProperty("java.version")
                    + "\nos.name = " + System.getProperty("os.name") + "\nos.arch = "
                    + System.getProperty("os.arch") + "\nos.version = " + System.getProperty("os.version"));
    exceptionArea.setEditable(false);
    exceptionArea.setWrapText(true);
    exceptionArea.setMaxWidth(UserInformation.getWindowWidth() / 2);
    exceptionArea.setMaxHeight(UserInformation.getWindowHeight() / 2);
    GridPane.setVgrow(exceptionArea, Priority.ALWAYS);
    GridPane.setHgrow(exceptionArea, Priority.ALWAYS);
    GridPane expContent = new GridPane();
    expContent.setMaxWidth(UserInformation.getWindowWidth() / 2);
    expContent.add(label, 0, 0);
    expContent.add(exceptionArea, 0, 1);
    alert.getDialogPane().setExpandableContent(expContent);
    return alert;
}

From source file:jlotoprint.MainViewController.java

public static void showExceptionAlert(String message, String details) {
    Alert alert = new Alert(Alert.AlertType.ERROR, message, ButtonType.OK);
    alert.initModality(Modality.APPLICATION_MODAL);
    alert.initOwner(JLotoPrint.stage.getScene().getWindow());
    TextArea textArea = new TextArea(details);
    textArea.setEditable(false);/*  w  w w.j  a v  a 2 s.c o m*/
    textArea.setWrapText(true);

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 0, 10));
    grid.add(textArea, 0, 0);

    //set content
    alert.getDialogPane().setExpandableContent(grid);
    alert.showAndWait();
}

From source file:jlotoprint.MainViewController.java

public static void loadAboutWindow() {

    //setup/*w  ww  .  j  av  a2  s  .c om*/
    Dialog dialog = new Dialog<>();
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.setTitle("About JLotoPanel");
    dialog.setHeaderText("JLotoPanel v1.0");
    ImageView icon = new ImageView("file:resources/icon.png");
    icon.setSmooth(true);
    icon.setFitHeight(48.0);
    icon.setFitWidth(48.0);
    dialog.setGraphic(icon);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(JLotoPrint.stage.getScene().getWindow());
    //content
    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 0, 10));

    //text
    TextArea textArea = new TextArea("For more info, please visit: https://github.com/mbppower/JLotoPanel");
    textArea.setWrapText(true);
    grid.add(textArea, 0, 0);
    dialog.getDialogPane().setContent(grid);

    dialog.showAndWait();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    TextField fName = new TextField();
    TextField lName = new TextField();
    TextField salary = new TextField();

    Button closeBtn = new Button("Close");
    closeBtn.setOnAction(e -> Platform.exit());

    fName.getProperties().put("microHelpText", "Enter the first name");
    lName.getProperties().put("microHelpText", "Enter the last name");
    salary.getProperties().put("microHelpText", "Enter a salary greater than $2000.00.");

    // The help text node is unmanaged
    helpText.setManaged(false);/*from w  w w .j  a v a2 s  . c o  m*/
    helpText.setTextOrigin(VPos.TOP);
    helpText.setFill(Color.RED);
    helpText.setFont(Font.font(null, 9));
    helpText.setMouseTransparent(true);

    // Add all nodes to a GridPane
    GridPane root = new GridPane();

    root.add(new Label("First Name:"), 1, 1);
    root.add(fName, 2, 1);
    root.add(new Label("Last Name:"), 1, 2);
    root.add(lName, 2, 2);

    root.add(new Label("Salary:"), 1, 3);
    root.add(salary, 2, 3);
    root.add(closeBtn, 3, 3);
    root.add(helpText, 4, 3);

    Scene scene = new Scene(root, 300, 100);

    // Add a change listener to the scene, so we know when
    // the focus owner changes and display the micro help   
    scene.focusOwnerProperty().addListener((ObservableValue<? extends Node> value, Node oldNode,
            Node newNode) -> focusChanged(value, oldNode, newNode));
    stage.setScene(scene);
    stage.setTitle("Showing Micro Help");
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("TitledPane");
    Scene scene = new Scene(new Group(), 450, 250);
    scene.setFill(Color.GHOSTWHITE);

    TitledPane gridTitlePane = new TitledPane();
    GridPane grid = new GridPane();
    grid.setVgap(4);// w ww  .j  ava2s. co m
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Cc: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Subject: "), 0, 2);
    grid.add(new TextField(), 1, 2);
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(new Label("static value"), 1, 3);
    gridTitlePane.setText("Grid");
    gridTitlePane.setContent(grid);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(gridTitlePane);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);

    TextField notification = new TextField();
    notification.setText("Label");

    notification.clear();/*from   w  ww . j  a  v a 2  s .  c  om*/

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(notification, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);

    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.getItems().addAll("A", "B", "C", "D", "E");
    emailComboBox.setValue("A");
    System.out.println(emailComboBox.getValue());

    GridPane grid = new GridPane();
    grid.setVgap(4);//  w  w  w  . j  a  va2s .co m
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.setItems(list);//from w ww .  j a  v  a  2  s.  co m
    emailComboBox.setValue("A");

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("TitledPane");
    Scene scene = new Scene(new Group(), 450, 250);
    scene.setFill(Color.GHOSTWHITE);

    Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("root.png")));

    TitledPane gridTitlePane = new TitledPane("Title", rootIcon);
    GridPane grid = new GridPane();
    grid.setVgap(4);//from  w  w w . j  av  a2 s .c  o m
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Cc: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Subject: "), 0, 2);
    grid.add(new TextField(), 1, 2);
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(new Label("static value"), 1, 3);
    gridTitlePane.setText("Grid");
    gridTitlePane.setContent(grid);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(gridTitlePane);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}