Java Code Examples for javafx.scene.layout.GridPane#setHgap()

The following examples show how to use javafx.scene.layout.GridPane#setHgap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExampleCss.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void buildAndShowMainWindow(Stage primaryStage) {
    primaryStage.setTitle("Hello World!!");
    GridPane gridPane = new GridPane();
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.setPadding(new Insets(25, 25, 25, 25));

    button = new Button("Click me!");
    button.setId("TheButton");
    gridPane.add(button,1,1);

    text = new TextField();
    gridPane.add(text, 2, 1);

    clockLabel = new Label();
    gridPane.add(clockLabel, 1,2, 2, 1);

    Scene scene = new Scene(gridPane);
    primaryStage.setScene(scene);
    scene.getStylesheets().add(getClass().getResource("/form.css").toExternalForm());
    primaryStage.show();
}
 
Example 2
Source File: SettingsMenu.java    From iliasDownloaderTool with GNU General Public License v2.0 6 votes vote down vote up
public SettingsMenu(Dashboard dashboard) {
	SettingsMenu.dashboard = dashboard;
	gridPane = new GridPane();
	setContentNode(gridPane);
	setArrowSize(0);
	setDetachable(false);
	hideOnEscapeProperty().set(true);
	/*
	 * @see http://stackoverflow.com/questions/25336796/tooltip-background-with
	 * -javafx-css
	 */
	this.getScene().getRoot().getStyleClass().add("main-root");
	/* ********************************************************** */
	gridPane.setPadding(new Insets(50, 50, 50, 50));
	gridPane.setHgap(20);
	gridPane.setVgap(20);
	initDialog();
	changeLocalIliasFolderButton();
}
 
Example 3
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    GridPane pane = new GridPane();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.setHgap(10);
    pane.setVgap(10);
    pane.add(clock1, 0, 0);
    pane.add(clock2, 0, 1);
    pane.add(clock3, 1, 0);
    pane.add(clock4, 1, 1);
    pane.add(clock5, 2, 0);
    pane.add(clock6, 2, 1);

    //Scene scene = new Scene(pane, 400, 400, Color.rgb(195, 195, 195));
    Scene scene = new Scene(pane, Color.BLACK);

    stage.setTitle("Clock Demo");
    stage.setScene(scene);
    stage.show();

    //clock.setMajorTickHeight(30);

    calcNoOfNodes(scene.getRoot());
    System.out.println("No. of nodes in scene: " + noOfNodes);
}
 
Example 4
Source File: ShortTimeFourierTransformSample.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private Node waveletSettingsPane() {
    final GridPane gridPane = new GridPane();
    gridPane.setVgap(5);
    gridPane.setHgap(3);
    gridPane.addRow(0, new Label("nu"), nu, new Label("[oscillations]"));
    nu.setEditable(true);
    gridPane.addRow(1, new Label("fMin"), waveletFMin, new Label("[fs]"));
    waveletFMin.setEditable(true);
    gridPane.addRow(2, new Label("fMax"), waveletFMax, new Label("[fs]"));
    waveletFMax.setEditable(true);
    gridPane.addRow(3, new Label("quantX"), quantx, new Label("samples"));
    quantx.setEditable(true);
    gridPane.addRow(4, new Label("quantY"), quanty, new Label("[samples]"));
    quanty.setEditable(true);
    installEventHandlers((evt) -> wavelet(rawData, waveletData), nu.valueProperty(), waveletFMin.valueProperty(), waveletFMax.valueProperty(), quantx.valueProperty(), quanty.valueProperty());
    return gridPane;
}
 
Example 5
Source File: PasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
public PasswordInputDialog() {
    super();
    pass = new PasswordField();
    grid = new GridPane();
    heading = new Label();

    heading.getStyleClass().add("label-heading");
    contentTextProperty().addListener((observable, oldVal, newVal) -> {
        heading.setText(newVal);
    });

    grid.setHgap(MainController.DIALOG_HGAP);
    grid.setVgap(MainController.DIALOG_VGAP);
    grid.addRow(0, heading, pass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(pass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            return pass.getText();
        }
        return null;
    });
}
 
Example 6
Source File: PatientView.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void layoutParts() {
  setSpacing(20);

  GridPane dashboard = new GridPane();
  RowConstraints growingRow = new RowConstraints();
  growingRow.setVgrow(Priority.ALWAYS);
  ColumnConstraints growingCol = new ColumnConstraints();
  growingCol.setHgrow(Priority.ALWAYS);
  dashboard.getRowConstraints().setAll(growingRow, growingRow);
  dashboard.getColumnConstraints().setAll(growingCol, growingCol);

  dashboard.setVgap(60);

  dashboard.setPrefHeight(800);
  dashboard.addRow(0, bloodPressureSystolicControl, bloodPressureDiastolicControl);
  dashboard.addRow(1, weightControl, tallnessControl);


  setHgrow(dashboard, Priority.ALWAYS);

  GridPane form = new GridPane();
  form.setHgap(10);
  form.setVgap(25);
  form.setMaxWidth(410);

  GridPane.setVgrow(imageView, Priority.ALWAYS);
  GridPane.setValignment(imageView, VPos.BOTTOM);

  form.add(firstNameField, 0, 0);
  form.add(lastNameField, 1, 0);
  form.add(yearOfBirthField, 0, 1);
  form.add(genderField, 1, 1);
  form.add(imageView, 0, 2, 2, 1);
  form.add(imgURLField, 0, 3, 2, 1);

  getChildren().addAll(form, dashboard);

}
 
Example 7
Source File: PropertiesAction.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Node createContent()
{
    final GridPane layout = new GridPane();
    layout.setHgap(5);
    layout.setVgap(5);

    int row = 0;

    final TextField filename = new TextField(file.getAbsolutePath());
    filename.setEditable(false);
    GridPane.setHgrow(filename, Priority.ALWAYS);
    layout.add(new Label(Messages.PropDlgPath), 0, row);
    layout.add(filename, 1, row);

    final TextField date = new TextField(TimestampFormats.MILLI_FORMAT.format(Instant.ofEpochMilli(file.lastModified())));
    date.setEditable(false);
    date.setMinWidth(200);
    GridPane.setHgrow(date, Priority.ALWAYS);
    layout.add(new Label(Messages.PropDlgDate), 0, ++row);
    layout.add(date, 1, row);

    if (!file.isDirectory())
    {
        final TextField size = new TextField(file.length() + " " + Messages.PropDlgBytes);
        size.setEditable(false);
        GridPane.setHgrow(size, Priority.ALWAYS);
        layout.add(new Label(Messages.PropDlgSize), 0, ++row);
        layout.add(size, 1, row);
    }

    layout.add(new Label(Messages.PropDlgPermissions), 0, ++row);
    layout.add(writable, 1, row);
    layout.add(executable, 1, ++row);

    writable.setSelected(file.canWrite());
    executable.setSelected(file.canExecute());

    return layout;
}
 
Example 8
Source File: DualPasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
public DualPasswordInputDialog(final ResourceBundle resources) {
    super();

    newLabel = new Label(resources.getString("dialogEncrypt.passNew"));
    repeatLabel = new Label(resources.getString("dialogEncrypt.passRepeat"));
    newPass = new PasswordField();
    repeatPass = new PasswordField();

    newLabel.getStyleClass().add("label-heading");
    repeatLabel.getStyleClass().add("label-heading");

    grid = new GridPane();
    grid.setHgap(DIALOG_HGAP);
    grid.setVgap(DIALOG_VGAP);
    grid.addRow(0, newLabel, newPass);
    grid.addRow(1, repeatLabel, repeatPass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(newPass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            if (!newPass.getText().trim().isEmpty() && !repeatPass.getText().trim().isEmpty()) {
                if (Objects.equals(newPass.getText(), repeatPass.getText())) {
                    return newPass.getText();
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
        return null;
    });
}
 
Example 9
Source File: ActivityDashboard.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void init() {
    GaugeBuilder builder = GaugeBuilder.create()
                                       .skinType(SkinType.SLIM)
                                       .barBackgroundColor(MaterialDesign.GREY_800.get())
                                       .animated(true)
                                       .animationDuration(1000);
    steps        = builder.decimals(0).maxValue(10000).unit("STEPS").build();
    distance     = builder.decimals(2).maxValue(10).unit("KM").build();
    actvCalories = builder.decimals(0).maxValue(2200).unit("KCAL").build();
    foodCalories = builder.decimals(0).maxValue(2200).unit("KCAL").build();
    weight       = builder.decimals(1).maxValue(85).unit("KG").build();
    bodyFat      = builder.decimals(1).maxValue(20).unit("%").build();

    VBox stepsBox        = getVBox("STEPS", MaterialDesign.CYAN_300.get(), steps);
    VBox distanceBox     = getVBox("DISTANCE", MaterialDesign.ORANGE_300.get(), distance);
    VBox actvCaloriesBox = getVBox("ACTIVE CALORIES", MaterialDesign.RED_300.get(), actvCalories);
    VBox foodCaloriesBox = getVBox("FOOD", MaterialDesign.GREEN_300.get(), foodCalories);
    VBox weightBox       = getVBox("WEIGHT", MaterialDesign.DEEP_PURPLE_300.get(), weight);
    VBox bodyFatBox      = getVBox("BODY FAT", MaterialDesign.PURPLE_300.get(), bodyFat);

    pane = new GridPane();
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(15);
    pane.setBackground(new Background(new BackgroundFill(MaterialDesign.GREY_900.get(), CornerRadii.EMPTY, Insets.EMPTY)));
    pane.add(stepsBox, 0, 0);
    pane.add(distanceBox, 1, 0);
    pane.add(actvCaloriesBox, 0, 2);
    pane.add(foodCaloriesBox, 1, 2);
    pane.add(weightBox, 0, 4);
    pane.add(bodyFatBox, 1, 4);
}
 
Example 10
Source File: WebViewBrowser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example 11
Source File: UserDetails.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
public static void display(final Stage primaryStage) {
	window = primaryStage;
	window.setTitle("Get Password By Email");
	final GridPane grid = new GridPane();
	grid.setPadding(new Insets(20, 20, 20, 2));
	grid.setVgap(8);
	grid.setHgap(10);

}
 
Example 12
Source File: Exercise_14_09.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a GridPane and set its properties
	GridPane gridPane = new GridPane();
	gridPane.setPadding(new Insets(10, 10, 10, 10));
	gridPane.setHgap(10);
	gridPane.setVgap(10);

	// Place nodes in the pane
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			// Create a stack pane
			StackPane stackPane = new StackPane();

			// Add circle to stack pane
			Circle circle = getCircle();
			stackPane.getChildren().add(circle);

			// Add Arcs to stack pane
			getArcs(stackPane);

			gridPane.add(stackPane, i, j);
		}
	}

	// Create a scene and place in in the stage
	Scene scene = new Scene(gridPane);
	primaryStage.setTitle("Exercise_14_09"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 13
Source File: ProductIonFilterSetHighlightDialog.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public ProductIonFilterSetHighlightDialog(@Nonnull Stage parent, ProductIonFilterPlot plot,
    String command) {

  this.desktop = MZmineCore.getDesktop();
  this.plot = plot;
  this.rangeType = command;
  mainPane = new DialogPane();
  mainScene = new Scene(mainPane);
  mainScene.getStylesheets()
      .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
  setScene(mainScene);
  initOwner(parent);
  String title = "Highlight ";
  if (command.equals("HIGHLIGHT_PRECURSOR")) {
    title += "precursor m/z range";
    axis = plot.getXYPlot().getDomainAxis();
  } else if (command.equals("HIGHLIGHT_NEUTRALLOSS")) {
    title += "neutral loss m/z range";
    axis = plot.getXYPlot().getRangeAxis();
  }
  setTitle(title);

  Label lblMinMZ = new Label("Minimum m/z");
  Label lblMaxMZ = new Label("Maximum m/z");

  NumberStringConverter converter = new NumberStringConverter();

  fieldMinMZ = new TextField();
  fieldMinMZ.setTextFormatter(new TextFormatter<>(converter));
  fieldMaxMZ = new TextField();
  fieldMaxMZ.setTextFormatter(new TextFormatter<>(converter));

  pnlLabelsAndFields = new GridPane();
  pnlLabelsAndFields.setHgap(5);
  pnlLabelsAndFields.setVgap(10);

  int row = 0;
  pnlLabelsAndFields.add(lblMinMZ, 0, row);
  pnlLabelsAndFields.add(fieldMinMZ, 1, row);

  row++;
  pnlLabelsAndFields.add(lblMaxMZ, 0, row);
  pnlLabelsAndFields.add(fieldMaxMZ, 1, row);

  // Create buttons
  mainPane.getButtonTypes().add(ButtonType.OK);
  mainPane.getButtonTypes().add(ButtonType.CANCEL);

  btnOK = (Button) mainPane.lookupButton(ButtonType.OK);
  btnOK.setOnAction(e -> {
    if (highlightDataPoints()) {
      hide();
    }
  });
  btnCancel = (Button) mainPane.lookupButton(ButtonType.CANCEL);
  btnCancel.setOnAction(e -> hide());

  mainPane.setContent(pnlLabelsAndFields);

  sizeToScene();
  centerOnScreen();
  setResizable(false);
}
 
Example 14
Source File: Exercise_16_17.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a stack pane for text
	StackPane paneForText = new StackPane(text);
	paneForText.setPadding(new Insets(20, 10, 5, 10));

	// Set slider properties
	slRed.setMin(0.0);
	slRed.setMax(1.0);
	slGreen.setMin(0.0);
	slGreen.setMax(1.0);
	slBlue.setMin(0.0);
	slBlue.setMax(1.0);
	slOpacity.setMin(0.0);
	slOpacity.setMax(1.0);

	// Create listeners
	slRed.valueProperty().addListener(ov -> setColor());
	slGreen.valueProperty().addListener(ov -> setColor());
	slBlue.valueProperty().addListener(ov -> setColor());
	slOpacity.valueProperty().addListener(ov -> setColor());
	slOpacity.setValue(1);


	// Create a grid pane for labeled sliders
	GridPane paneForSliders = new GridPane();
	paneForSliders.setAlignment(Pos.CENTER);
	paneForSliders.setVgap(5);
	paneForSliders.setHgap(5);
	paneForSliders.add(new Label("Red"), 0, 0);
	paneForSliders.add(slRed, 1, 0);
	paneForSliders.add(new Label("Green"), 0, 1);
	paneForSliders.add(slGreen, 1, 1);
	paneForSliders.add(new Label("Blue"), 0, 2);
	paneForSliders.add(slBlue, 1, 2);
	paneForSliders.add(new Label("Opacity"), 0, 3);
	paneForSliders.add(slOpacity, 1, 3);

	// Place nodes in a border pane
	BorderPane pane = new BorderPane();
	pane.setTop(paneForText);
	pane.setCenter(paneForSliders);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 250, 150);
	primaryStage.setTitle("Exercise_16_17"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 15
Source File: PasswordDialogController.java    From chvote-1-0 with GNU Affero General Public License v3.0 4 votes vote down vote up
private void openPasswordInputDialog(StringProperty target, int groupNumber, boolean withConfirmation) throws ProcessInterruptedException {
    Dialog<String> dialog = new Dialog<>();
    String title = String.format(resources.getString("password_dialog.title"), groupNumber);
    dialog.setTitle(title);
    dialog.getDialogPane().getStylesheets().add("/ch/ge/ve/offlineadmin/styles/offlineadmin.css");
    dialog.getDialogPane().getStyleClass().addAll("background", "password-dialog");

    // Define and add buttons
    ButtonType confirmPasswordButtonType = new ButtonType(resources.getString("password_dialog.confirm_button"), ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(confirmPasswordButtonType, ButtonType.CANCEL);

    // Create header label
    Label headerLabel = new Label(title);
    headerLabel.getStyleClass().add("header-label");

    // Create the input labels and fields
    GridPane grid = new GridPane();
    grid.setHgap(GRID_GAP);
    grid.setVgap(GRID_GAP);
    grid.setPadding(GRID_INSETS);

    TextField electionOfficer1Password = new TextField();
    String electionOfficer1Label = withConfirmation ? resources.getString("password_dialog.election_officer_1")
            : resources.getString("password_dialog.election_officer");
    electionOfficer1Password.setPromptText(electionOfficer1Label);
    electionOfficer1Password.setId("passwordField1");

    TextField electionOfficer2Password = new TextField();
    String electionOfficer2Label = resources.getString("password_dialog.election_officer_2");
    electionOfficer2Password.setPromptText(electionOfficer2Label);
    electionOfficer2Password.setId("passwordField2");

    // Create error message label
    Label errorMessage = createErrorMessage(withConfirmation);
    errorMessage.setId("errorLabel");

    // Position the labels and fields
    int row = 0;
    grid.add(headerLabel, LABEL_COL, row, 2, 1);
    row++;
    grid.add(new Label(electionOfficer1Label), LABEL_COL, row);
    grid.add(electionOfficer1Password, INPUT_COL, row);
    if (withConfirmation) {
        row++;
        grid.add(new Label(electionOfficer2Label), LABEL_COL, row);
        grid.add(electionOfficer2Password, INPUT_COL, row);
    }
    row++;
    grid.add(errorMessage, LABEL_COL, row, 2, 1);

    dialog.getDialogPane().setContent(grid);

    // Perform input validation
    Node confirmButton = dialog.getDialogPane().lookupButton(confirmPasswordButtonType);
    confirmButton.setDisable(true);

    BooleanBinding booleanBinding = bindForValidity(withConfirmation, electionOfficer1Password, electionOfficer2Password, errorMessage, confirmButton);

    // Convert the result
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == confirmPasswordButtonType) {
            return electionOfficer1Password.textProperty().getValueSafe();
        } else {
            return null;
        }
    });

    Platform.runLater(electionOfficer1Password::requestFocus);

    Optional<String> result = dialog.showAndWait();

    //if not disposed then we do have binding errors if this method is run again
    booleanBinding.dispose();
    result.ifPresent(target::setValue);

    if (!result.isPresent()) {
        throw new ProcessInterruptedException("Password input cancelled");
    }
}
 
Example 16
Source File: SeparatorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 350, 150);
    stage.setScene(scene);
    stage.setTitle("Separator Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(2);
    grid.setHgap(5);

    scene.setRoot(grid);
    scene.getStylesheets().add("separatorsample/controlStyle.css");

    Image cloudImage = new Image(getClass().getResourceAsStream("cloud.jpg"));
    Image sunImage = new Image(getClass().getResourceAsStream("sun.jpg"));

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    friday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(friday, 0, 2);
    GridPane.setColumnSpan(friday, 2);
    grid.getChildren().add(friday);

    final Separator sepVert1 = new Separator();
    sepVert1.setOrientation(Orientation.VERTICAL);
    sepVert1.setValignment(VPos.CENTER);
    sepVert1.setPrefHeight(80);
    GridPane.setConstraints(sepVert1, 2, 2);
    GridPane.setRowSpan(sepVert1, 2);
    grid.getChildren().add(sepVert1);

    saturday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(saturday, 3, 2);
    GridPane.setColumnSpan(saturday, 2);
    grid.getChildren().add(saturday);

    final Separator sepVert2 = new Separator();
    sepVert2.setOrientation(Orientation.VERTICAL);
    sepVert2.setValignment(VPos.CENTER);
    sepVert2.setPrefHeight(80);
    GridPane.setConstraints(sepVert2, 5, 2);
    GridPane.setRowSpan(sepVert2, 2);
    grid.getChildren().add(sepVert2);

    sunday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(sunday, 6, 2);
    GridPane.setColumnSpan(sunday, 2);
    grid.getChildren().add(sunday);

    final ImageView cloud = new ImageView(cloudImage);
    GridPane.setConstraints(cloud, 0, 3);
    grid.getChildren().add(cloud);

    final Label t1 = new Label("16");
    t1.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t1, 1, 3);
    grid.getChildren().add(t1);

    final ImageView sun1 = new ImageView(sunImage);
    GridPane.setConstraints(sun1, 3, 3);
    grid.getChildren().add(sun1);

    final Label t2 = new Label("18");
    t2.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t2, 4, 3);
    grid.getChildren().add(t2);

    final ImageView sun2 = new ImageView(sunImage);
    GridPane.setConstraints(sun2, 6, 3);
    grid.getChildren().add(sun2);

    final Label t3 = new Label("20");
    t3.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t3, 7, 3);
    grid.getChildren().add(t3);

    stage.show();
}
 
Example 17
Source File: ViewUtil.java    From ClusterDeviceControlPlatform with MIT License 4 votes vote down vote up
public static Optional<Pair<String, String>> ConnDialogResult() {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("建立连接");
        dialog.setHeaderText("请输入服务器的连接信息");


        ButtonType loginButtonType = new ButtonType("连接", ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

        // Create the username and password labels and fields.
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField hostName = new TextField();
        hostName.setPromptText("localhost");
        hostName.setText("localhost");
        TextField port = new TextField();
        port.setPromptText("30232");
        port.setText("30232");

        grid.add(new Label("主机名: "), 0, 0);
        grid.add(hostName, 1, 0);
        grid.add(new Label("端口号: "), 0, 1);
        grid.add(port, 1, 1);

        // Enable/Disable login button depending on whether a username was entered.
        //       Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        //  loginButton.setDisable(true);

        // Do some validation (using the Java 8 lambda syntax).
//        hostName.textProperty().addListener((observable, oldValue, newValue) -> {
//            loginButton.setDisable(newValue.trim().isEmpty());
//        });

        dialog.getDialogPane().setContent(grid);

        // Request focus on the username field by default.
        Platform.runLater(() -> hostName.requestFocus());

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(hostName.getText(), port.getText());
            }
            return null;
        });

        return dialog.showAndWait();
    }
 
Example 18
Source File: IconEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void updateItem(String item, boolean empty) {
    super.updateItem(item, empty);
    if (item != null) {
        final GridPane gridPane = new GridPane();
        gridPane.setHgap(0);
        gridPane.setAlignment(Pos.TOP_LEFT);

        // icon
        final ConstellationIcon icon = IconManager.getIcon(item);
        final Image iconImage = icon.buildImage();
        final ImageView imageView = new ImageView(iconImage);
        imageView.setPreserveRatio(true);
        imageView.setFitHeight(RECT_SIZE);
        final ColumnConstraints titleConstraint = new ColumnConstraints(RECT_SIZE);
        titleConstraint.setHalignment(HPos.CENTER);
        gridPane.getColumnConstraints().addAll(titleConstraint);
        gridPane.add(imageView, 0, 0);

        // dimension text
        if (iconImage != null) {
            final int width = (int) (iconImage.getWidth());
            final int height = (int) (iconImage.getHeight());
            final Text dimensionText = new Text(String.format("(%dx%d)", width, height));
            dimensionText.setFill(Color.web("#d3d3d3"));
            gridPane.add(dimensionText, 0, 1);
        }

        // icon name
        final String displayableItem = icon.getExtendedName();
        final String[] splitItem = displayableItem.split("\\.");
        String iconName = splitItem[splitItem.length - 1];
        if (iconName.isEmpty()) {
            iconName = "(no icon)";
        }
        this.setText(iconName);

        // tooltip
        final Tooltip tt = new Tooltip(item);
        this.setTooltip(tt);

        this.setGraphic(gridPane);
        this.setPrefHeight(RECT_SIZE + SPACING);
    } else {
        this.setText(null);
        this.setGraphic(null);
    }
}
 
Example 19
Source File: MetadataOverview.java    From sis with Apache License 2.0 4 votes vote down vote up
private GridPane createSpatialGridPane() {
    GridPane gp = new GridPane();
    gp.setHgap(10.00);
    gp.setVgap(10.00);
    int j = 0, k = 1;

    Collection<? extends ReferenceSystem> referenceSystemInfos = metadata.getReferenceSystemInfo();
    if (!referenceSystemInfos.isEmpty()) {
        ReferenceSystem referenceSystemInfo = referenceSystemInfos.iterator().next();
        Label rsiValue = new Label("Reference system infos: " + referenceSystemInfo.getName().toString());
        rsiValue.setWrapText(true);
        gp.add(rsiValue, j, k++);
    }

    Collection<? extends SpatialRepresentation> sris = this.metadata.getSpatialRepresentationInfo();
    if (sris.isEmpty()) {
        return gp;
    }
    NumberFormat numberFormat = NumberFormat.getIntegerInstance(locale);
    for (SpatialRepresentation sri : sris) {
        String currentValue = "• ";
        if (sri instanceof DefaultGridSpatialRepresentation) {
            DefaultGridSpatialRepresentation sr = (DefaultGridSpatialRepresentation) sri;

            Iterator<? extends Dimension> it = sr.getAxisDimensionProperties().iterator();
            while (it.hasNext()) {
                Dimension dim = it.next();
                currentValue += numberFormat.format(dim.getDimensionSize()) + " " + Types.getCodeTitle(dim.getDimensionName()) + " * ";
            }
            currentValue = currentValue.substring(0, currentValue.length() - 3);
            Label spRep = new Label(currentValue);
            gp.add(spRep, j, k++, 2, 1);
            if (sr.getCellGeometry() != null) {
                Label cellGeo = new Label("Cell geometry:");
                Label cellGeoValue = new Label(Types.getCodeTitle(sr.getCellGeometry()).toString());
                cellGeoValue.setWrapText(true);
                gp.add(cellGeo, j, k);
                gp.add(cellGeoValue, ++j, k++);
                j = 0;
            }
        }
    }
    return gp;
}
 
Example 20
Source File: ActionsDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** @return Sub-pane for ExecuteCommand action */
private GridPane createExecuteCommandDetails()
{
    final InvalidationListener update = whatever ->
    {
        if (updating  ||  selected_action_index < 0)
            return;
        actions.set(selected_action_index, getExecuteCommandAction());
    };

    final GridPane execute_command_details = new GridPane();
    execute_command_details.setHgap(10);
    execute_command_details.setVgap(10);

    execute_command_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    execute_command_description.textProperty().addListener(update);
    execute_command_details.add(execute_command_description, 1, 0);
    GridPane.setHgrow(execute_command_description, Priority.ALWAYS);

    execute_command_details.add(new Label(Messages.ActionsDialog_Command), 0, 1);
    execute_command_file.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event ->
    {
        try
        {
            final String path = FilenameSupport.promptForRelativePath(widget, execute_command_file.getText());
            if (path != null)
                execute_command_file.setText(path);
            FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot prompt for filename", ex);
        }
    });
    final HBox path_box = new HBox(execute_command_file, select);
    HBox.setHgrow(execute_command_file, Priority.ALWAYS);
    execute_command_details.add(path_box, 1, 1);

    return execute_command_details;
}