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 stage) {
    Text msg = new Text("java2s.com");
    msg.setTextOrigin(VPos.TOP);//from  ww  w  . j  a va2s  .c  o m
    msg.setFont(Font.font(24));

    Pane root = new Pane(msg);
    root.setPrefSize(500, 70);
    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.setTitle("Scrolling Text");
    stage.show();

    double sceneWidth = scene.getWidth();
    double msgWidth = msg.getLayoutBounds().getWidth();

    KeyValue initKeyValue = new KeyValue(msg.translateXProperty(), sceneWidth);
    KeyFrame initFrame = new KeyFrame(Duration.ZERO, initKeyValue);

    KeyValue endKeyValue = new KeyValue(msg.translateXProperty(), -1.0 * msgWidth);
    KeyFrame endFrame = new KeyFrame(Duration.seconds(3), endKeyValue);

    Timeline timeline = new Timeline(initFrame, endFrame);

    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
}

From source file:br.com.ajaio.midas.desktop.controller.DashBoardController.java

public void addConta() throws IOException {
    Stage stage = new Stage();
    Parent root = FXMLLoader.load(MainApp.class.getResource("view/popContaFormFXML.fxml"));
    stage.setTitle("Add new entry");
    stage.setScene(new Scene(root, 800, 600));
    stage.show();/* w ww .j  a  v  a2s  .  c o m*/
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group group = new Group();

    Rectangle rect = new Rectangle(20, 20, 200, 200);

    rect.setStrokeWidth(2);//from   w  w  w.j a  v a  2  s.  c o  m

    rect.setStroke(Color.RED);
    group.getChildren().add(rect);

    Scene scene = new Scene(group, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    ChoiceBox choiceBox = new ChoiceBox(cursors);

    System.out.println(choiceBox.getConverter());
    VBox box = new VBox();
    box.getChildren().add(choiceBox);/*  ww  w .j  a  v  a 2s  .com*/
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.initStyle(StageStyle.UTILITY);
    Text text = new Text("!");
    text.setFont(new Font(40));
    VBox box = new VBox();
    box.getChildren().add(text);/*from w  w  w  .  ja  v a2 s.c  om*/
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.initStyle(StageStyle.DECORATED);
    Text text = new Text("!");
    text.setFont(new Font(40));
    VBox box = new VBox();
    box.getChildren().add(text);//from ww w.j av a 2  s  . c o m
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    ChoiceBox choiceBox = new ChoiceBox(cursors);

    System.out.println(choiceBox.getSelectionModel());
    VBox box = new VBox();
    box.getChildren().add(choiceBox);/*from w ww . java 2 s .  c o  m*/
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    ChoiceBox choiceBox = new ChoiceBox(cursors);

    System.out.println(choiceBox.converterProperty());
    VBox box = new VBox();
    box.getChildren().add(choiceBox);//from   ww  w  .  j a  va2 s. c o  m
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    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, Color.RED);

    System.out.println(circ.radiusProperty().doubleValue());

    final Group root = new Group(circ);
    final Scene scene = new Scene(root, 400, 300);

    primaryStage.setScene(scene);
    primaryStage.show();/*from   w  ww  .j  a v  a  2 s  .  c  o  m*/
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Button okBtn = new Button("OK");
    Button cancelBtn = new Button("Cancel");

    cancelBtn.setPrefWidth(100);//from w ww. j  a v a 2  s. co  m

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

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Overriding Node Sizes");
    stage.show();

    System.out.println("okBtn.getPrefWidth(): " + okBtn.getPrefWidth());
    System.out.println("okBtn.getMinWidth(): " + okBtn.getMinWidth());
    System.out.println("okBtn.getMaxWidth(): " + okBtn.getMaxWidth());

    System.out.println("cancelBtn.getPrefWidth(): " + cancelBtn.getPrefWidth());
    System.out.println("cancelBtn.getMinWidth(): " + cancelBtn.getMinWidth());
    System.out.println("cancelBtn.getMaxWidth(): " + cancelBtn.getMaxWidth());
}