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) {

    ObservableList<String> data = FXCollections.observableArrayList();

    ListView<String> listView = new ListView<String>(data);
    listView.setPrefSize(200, 250);/*from  w w  w  .ja  va2s .  c  o m*/
    listView.setEditable(true);

    data.addAll("A", "B", "C", "D", "E");

    listView.setItems(data);
    listView.setCellFactory((ListView<String> l) -> new ColorRectCell());
    StackPane root = new StackPane();
    root.getChildren().add(listView);
    primaryStage.setScene(new Scene(root, 200, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");
    Group root = new Group();
    Scene scene = new Scene(root, 550, 250, Color.WHITE);

    Text text = new Text(50, 50, "JavaFX 2.0 from Java2s.com");
    Font monoFont = Font.font("Dialog", 30);
    text.setFont(monoFont);// w w  w.  jav  a2s.c o  m
    text.setFill(Color.BLACK);
    root.getChildren().add(text);

    Reflection refl = new Reflection();
    refl.setFraction(0.8f);
    text.setEffect(refl);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Sample");
    stage.setWidth(300);/*from w ww . ja  va  2  s . c o  m*/
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    Rectangle rect = new Rectangle(50, 50, Color.RED);
    rect.getTransforms().add(new Rotate(45, 0, 0)); //

    vbox.getChildren().add(rect);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

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

From source file:at.ac.tuwien.qse.sepm.gui.App.java

@Override
public void start(Stage stage) throws Exception {
    logger.info("Application started.");

    FXMLLoader loader = new FXMLLoader();
    loader.setControllerFactory(context::getBean);

    // set base location so that resources can be loaded using relative paths
    loader.setLocation(getClass().getClassLoader().getResource("view"));

    Parent root = loader.load(getClass().getClassLoader().getResourceAsStream("view/Main.fxml"));

    stage.setScene(new Scene(root));

    stage.setTitle("travelimg");
    stage.getIcons().add(getApplicationIcon());
    stage.show();// w  ww. j a  v  a 2s  . com

    PhotoService photoService = (PhotoService) context.getBean("photoService");
    photoService.initializeRepository();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 551, 400, Color.BLACK);
    Group buttonGroup = new Group();
    Arc rightButton = ArcBuilder.create().type(ArcType.ROUND).radiusX(15).radiusY(15).startAngle(180 - 30)
            .length(60).translateX(40).build();
    buttonGroup.getChildren().add(rightButton);
    buttonGroup.translateYProperty().bind(scene.heightProperty().subtract(10));
    root.getChildren().add(buttonGroup);

    primaryStage.setScene(scene);
    primaryStage.show();//from  w w  w  . j  a v a2s .  c o  m
}

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  ww w. ja v  a 2 s  .c o m
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search");
    label1.setGraphic(new ImageView(image));

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

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

From source file:com.toyota.carservice.SplashScreen.java

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/com/toyota/carservice/view/formSplash.fxml"));
    Scene scene = new Scene(root);
    stage.setTitle("Connection to database...");
    ApplicationContext appContex = config.getInstance().getApplicationContext();
    Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
    stage.getIcons().add(new Image(resource.getURI().toString()));
    stage.setScene(scene);
    stage.initStyle(StageStyle.UNDECORATED);
    stage.show();//w w  w  . j a v  a  2 s  .  com
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);//from   w w  w . j  ava 2s .c o  m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());
    VBox root = new VBox();

    Hyperlink hpl = new Hyperlink("java2s.com");

    Image image1 = new Image(new File("a.jpg").toURI().toString(), 0, 100, false, false);
    hpl.setFont(Font.font("Arial", 14));
    hpl.setGraphic(new ImageView(image1));
    root.getChildren().addAll(hpl);

    scene.setRoot(root);

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

From source file:Main.java

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

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    TitledPane t1 = new TitledPane("T1", new Button("B1"));
    TitledPane t2 = new TitledPane("T2", new Button("B2"));
    TitledPane t3 = new TitledPane("T3", new Button("B3"));
    Accordion accordion = new Accordion();
    accordion.getPanes().addAll(t1, t2, t3);

    g.getChildren().add(accordion);/*from w w  w. ja v a2s .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(), 450, 250);

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

    notification.clear();/* ww w . j  ava2 s .  co  m*/

    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();
}