예제 #1
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    Button okBtn = new Button(Msg.get(this, "ok"));
    Button cancelBtn = new Button(Msg.get(this, "cancel"));

    // Set the location of the OK button
    okBtn.setLayoutX(10);
    cancelBtn.setLayoutY(10);

    // Set the location of the Cancel button relative to the OK button
    NumberBinding layoutXBinding = okBtn.layoutXProperty().add(okBtn.widthProperty().add(10));
    cancelBtn.layoutXProperty().bind(layoutXBinding);

    //
    cancelBtn.layoutYProperty().bind(okBtn.layoutYProperty());

    //
    Group root = new Group();
    root.getChildren().addAll(okBtn, cancelBtn);

    //
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
예제 #2
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    // Add mouse click event handler to the canvas to show the context menu
    canvas.setOnMouseClicked(this::showContextMenu);

    //
    BorderPane root = new BorderPane(canvas);
    root.setTop(new Label(Msg.get(this, "label.info")));
    root.setStyle(Msg.get(FlowPaneApp.class, "style"));

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
예제 #3
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle(Msg.get(this, "title"));

    primaryStage.setOpacity(Msg.get(this, "stage.opacity", Double::parseDouble, 1.0));

    Group root = new Group();
    Button btnHello = new Button(Msg.get(this, "btnHello.text"));
    root.getChildren().add(btnHello);

    Scene scene =
        new Scene(
            root,
            Msg.get(this, "scene.width", Integer::parseInt, 300),
            Msg.get(this, "scene.height", Integer::parseInt, 300));
    primaryStage.setScene(scene);
    //		primaryStage.sizeToScene();
    primaryStage.setWidth(Msg.get(this, "stage.width", Integer::parseInt, 300));
    primaryStage.setHeight(Msg.get(this, "stage.height", Integer::parseInt, 300));
    primaryStage.show();

    // Center the stage to window only after the stage has been shown
    Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
    double x = bounds.getMinX() + (bounds.getWidth() - primaryStage.getWidth()) / 2;
    double y = bounds.getMinY() + (bounds.getHeight() - primaryStage.getHeight()) / 2;

    //
    primaryStage.setX(x);
    primaryStage.setY(y);
  }
예제 #4
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Label fnameLbl = new Label(Msg.get(this, "firstName"));
    TextField fnameFld = new TextField();
    Label lnameLbl = new Label(Msg.get(this, "lastName"));
    TextField lnameFld = new TextField();
    Button okBtn = new Button(Msg.get(this, "OK"));
    Button cancelBtn = new Button(Msg.get(this, "cancel"));

    // The OK button should fill its cell
    okBtn.setMaxWidth(Double.MAX_VALUE);

    // Create a GridPane and set its background color to lightgray
    GridPane root = new GridPane();
    root.setGridLinesVisible(true);
    root.setHgap(10);
    root.setVgap(5);
    root.setStyle(Msg.get(this, "style"));

    // Add children to teh GridPane
    root.addRow(0, fnameLbl, fnameFld, okBtn);
    root.addRow(1, lnameLbl, lnameFld, cancelBtn);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
예제 #5
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    ColorPicker bgColor =
        new ColorPicker(Msg.get(this, "color.initial", Color::valueOf, Color.BLANCHEDALMOND));

    // A Rectangle to show the selected color from teh color picker
    Rectangle rect = new Rectangle(0, 0, 100, 50);
    rect.setFill(bgColor.getValue());
    rect.setStyle(Msg.get(this, "rect.style"));

    // Add an ActionEvetn handler to the ColorPicker, so you change
    // the fill color for the rectangle when you pick a new color
    bgColor.setOnAction(e -> rect.setFill(bgColor.getValue()));

    //
    HBox root = new HBox(10, new Label(Msg.get(this, "label.color")), bgColor, rect);
    root.setStyle(Msg.get(FlowPaneApp.class, "style"));

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }