Example usage for javafx.stage Stage setScene

List of usage examples for javafx.stage Stage setScene

Introduction

In this page you can find the example usage for javafx.stage Stage setScene.

Prototype

@Override
final public void setScene(Scene value) 

Source Link

Document

Specify the scene to be used on this stage.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 551, 400);
    Group buttonGroup = new Group();
    Rectangle buttonArea = RectangleBuilder.create().arcWidth(15).arcHeight(20).fill(new Color(0, 0, 0, .55))
            .x(0).y(0).width(60).height(30).stroke(Color.BLACK).build();
    buttonGroup.getChildren().add(buttonArea);
    root.getChildren().add(buttonGroup);

    primaryStage.setScene(scene);
    primaryStage.show();/*  www.  java2  s.  c o m*/
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*from   w  w w  .  j  a v  a 2s.co  m*/
    stage.setHeight(150);

    Button button = new Button("Hover Over Me");
    Tooltip toolTip = new Tooltip("Tooltip for Button");
    toolTip.setWrapText(true);
    System.out.println(toolTip.wrapTextProperty());

    button.setTooltip(toolTip);

    ((Group) scene.getRoot()).getChildren().add(button);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");

    final Circle circ = new Circle(40, 40, 30);
    final Group root = new Group(circ);

    final Scene scene = new Scene(root, 800, 400, Color.BEIGE);

    final Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.DARKBLUE);
    text1.setFont(Font.font(java.awt.Font.SERIF, 25));
    root.getChildren().add(text1);//from  ww w . ja  va2  s.c o  m

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*from w  w w  . j av  a2 s  .  com*/
    stage.setHeight(150);

    Button button = new Button("Hover Over Me");
    Tooltip toolTip = new Tooltip("Tooltip for Button");
    toolTip.setWrapText(true);
    System.out.println(toolTip.textAlignmentProperty());

    button.setTooltip(toolTip);
    ((Group) scene.getRoot()).getChildren().add(button);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");

    final Circle circ = new Circle(40, 40, 30);
    final Group root = new Group(circ);

    final Scene scene = new Scene(root, 800, 400, Color.BEIGE);

    final Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.CHOCOLATE);
    text1.setFont(Font.font(java.awt.Font.SERIF, 25));
    root.getChildren().add(text1);/* w  w  w . j  a v  a 2 s .  c o  m*/

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);/*from w w  w .  java  2 s  .  c o m*/
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTextAlignment(TextAlignment.JUSTIFY);

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    TreeItem<String> rootItem = new TreeItem<>("Root");
    rootItem.setExpanded(true);//from w  ww  .j  a v  a2 s . co  m

    TreeItem<String> item = new TreeItem<>("A");
    rootItem.getChildren().add(item);

    item = new TreeItem<>("B");
    rootItem.getChildren().add(item);

    TreeView<String> tree = new TreeView<>(rootItem);
    StackPane root = new StackPane();
    root.getChildren().add(tree);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setWidth(500);//from  ww  w. j a  v a  2  s  . c  o m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();
    NumberAxis lineYAxis = new NumberAxis(0, 100, 10);
    CategoryAxis lineXAxis = new CategoryAxis();

    lineYAxis.setLabel("Sales");
    lineXAxis.setLabel("Products");

    root.getChildren().addAll(lineXAxis);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);/*  www .  j  a va  2  s .  c om*/
    Stop[] stops = new Stop[] { new Stop(0, Color.BLACK), new Stop(1, Color.RED) };
    LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);

    Rectangle r1 = new Rectangle(0, 0, 100, 100);
    r1.setFill(lg1);

    box.getChildren().add(r1);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    msgLbl.setPrefWidth(150);//from w  ww.  j a  v a 2  s . c om

    sayHelloBtn.setOnAction(this::sayHello);

    VBox root = new VBox(10);
    root.getChildren().addAll(msgLbl, sayHelloBtn);
    root.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;"
            + "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: blue;");
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Hello FXML");
    stage.show();
}