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) {
    Scene scene = new Scene(new Group(), 450, 250);
    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setValue("A");
    System.out.println(myComboBox.getValue());

    myComboBox.setValue(null);//w w  w .  jav a2 s.  c  om

    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);
    stage.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);// www  .  j  a  v  a 2 s  .  c o  m
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setRotate(270);

    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) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart barChart = new BarChart(xAxis, yAxis, getChartData());
    barChart.setBarGap(0.2);//from   w  ww.j  a  v  a  2 s.c o  m
    barChart.setTitle("A");
    primaryStage.setTitle("BarChart example");

    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    primaryStage.setScene(new Scene(root, 400, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) throws Exception {
    Group rootGroup = new Group();
    Scene scene = new Scene(rootGroup, 800, 400);

    Text text1 = new Text(25, 25, "java2s.com");
    text1.setFill(Color.CHOCOLATE);
    text1.setFont(Font.font(java.awt.Font.MONOSPACED, 35));

    Effect glow = new Glow(1.0);
    text1.setEffect(glow);//w w w. ja v a 2  s .  c  o m

    rootGroup.getChildren().add(text1);

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

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTranslateY(50);

    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) {
    vb.setId("root");

    WebView browser = new WebView();
    WebEngine engine = browser.getEngine();
    String url = "http://java2s.com/";
    engine.load(url);// ww  w .  j  a va 2 s  . c om

    vb.setPadding(new Insets(30, 50, 50, 50));
    vb.setSpacing(10);
    vb.setAlignment(Pos.CENTER);
    vb.getChildren().addAll(browser);

    Scene scene = new Scene(vb);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

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

    //Creating StackPane
    StackPane sp = new StackPane();

    ///*from   ww w .  ja  v a2 s .  c  o m*/
    Label lbl = new Label("JavaFX 2 StackPane");
    sp.getChildren().add(lbl);
    Button btn = new Button("Button");
    sp.getChildren().add(btn);

    //Adding StackPane to the scene
    Scene scene = new Scene(sp, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:ijfx.ui.filter.FilterTest.java

@Override
public void start(Stage primaryStage) throws Exception {

    borderPane = new BorderPane();

    borderPane.getStylesheets().add(ImageJFX.getStylesheet());
    borderPane.getStyleClass().add("explorer-filter");
    Button updateButton = new Button("Update values");

    filter = new DefaultNumberFilter();
    Scene scene = new Scene(borderPane);
    primaryStage.setScene(scene);

    borderPane.setCenter(filter.getContent());
    borderPane.setBottom(updateButton);/*from   w w w. j  ava  2 s . c om*/

    updateButton.setOnAction(this::update);

    primaryStage.show();

}

From source file:ipat_fx.IPAT_FX.java

@Override
public void start(Stage stage) throws Exception {
    String contextPath = System.getProperty("user.dir") + "/web/";
    File logFile = new File(contextPath + "/log/log4j-IPAT.log");
    System.setProperty("rootPath", logFile.getAbsolutePath());

    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();//from   w  w w. j  a v  a 2  s  .com
    stage.setOnHiding((WindowEvent event) -> {
        Platform.runLater(() -> {
            File src = new File(contextPath + "/Client Data");
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
            Date date = new Date();
            File dest = new File(contextPath + "/Saves/Ipat_" + dateFormat.format(date));
            if (!dest.exists()) {
                dest.mkdirs();
            }
            try {
                FileUtils.copyDirectory(src, dest);
            } catch (IOException ex) {
                Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex);
            }
            System.exit(0);
        });
    });
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    PieChart pieChart = new PieChart();
    pieChart.setData(getChartData());//from www. jav  a2  s  .  co  m

    System.out.println(pieChart.getData());

    pieChart.setTitle("Title");
    pieChart.setLegendSide(Side.LEFT);
    pieChart.setClockwise(false);
    pieChart.setLabelsVisible(false);

    StackPane root = new StackPane();
    root.getChildren().add(pieChart);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}