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) {
    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));
    final Effect glow = new Glow(1.0);
    text1.setEffect(glow);//from  w  w  w  .  j  a  v  a 2s  . c  o  m
    root.getChildren().add(text1);

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

From source file:Main.java

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

    Group root = new Group();
    Scene scene = new Scene(root, 300, 150, Color.GRAY);

    Line redLine = new Line(10, 10, 200, 10);

    redLine.setStroke(Color.RED);
    redLine.setStrokeWidth(10);/* w  w w.j  a v  a 2 s.  c  om*/
    redLine.setStrokeLineCap(StrokeLineCap.BUTT);

    redLine.getStrokeDashArray().addAll(15d, 5d, 15d, 15d, 20d);
    redLine.setStrokeDashOffset(10);

    root.getChildren().add(redLine);

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

From source file:com.toyota.carservice.config.config2.java

public Object newStage3(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style,
        boolean maximized) {
    try {//ww  w.  java 2 s .co m
        Stage st = new Stage();
        stage = (Stage) lb.getScene().getWindow();
        FXMLLoader root = new FXMLLoader(getClass().getResource(load));

        Scene scene = new Scene(root.load());
        st.initStyle(style);
        st.setResizable(resize);
        st.setMaximized(maximized);
        st.setTitle(judul);
        st.setScene(scene);
        ApplicationContext appContex = config.getInstance().getApplicationContext();
        Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
        st.getIcons().add(new Image(resource.getURI().toString()));
        st.show();
        return root.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);//from  w ww. j a  v a2  s.  co  m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    Path path = new Path();
    path.getElements().add(new MoveTo(50.0f, 0.0f));
    VLineTo vlt = new VLineTo(50.0f);
    vlt.setY(.7);
    path.getElements().add(vlt);

    System.out.println(vlt.getY());

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

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

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);//from  w w  w.  ja  v  a 2 s  .  co m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    Path path = new Path();
    path.getElements().add(new MoveTo(50.0f, 0.0f));
    VLineTo vlt = new VLineTo();
    vlt.setY(.7);
    path.getElements().add(vlt);

    System.out.println(vlt.yProperty());

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

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

From source file:com.toyota.carservice.config.config2.java

public Object newStage(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style,
        boolean maximized) {
    try {/*w w w  . j  ava2s .c o m*/
        Stage st = new Stage();
        stage = (Stage) lb.getScene().getWindow();
        FXMLLoader root = new FXMLLoader(getClass().getResource(load));

        Scene scene = new Scene(root.load());
        st.initStyle(style);
        st.setResizable(resize);
        st.setMaximized(maximized);
        st.setTitle(judul);
        st.setScene(scene);
        ApplicationContext appContex = config.getInstance().getApplicationContext();
        Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
        st.getIcons().add(new Image(resource.getURI().toString()));
        st.show();
        stage.close();
        return root.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.toyota.carservice.config.config2.java

public Object newStage2(Stage stage, Button lb, String load, String judul, boolean resize, StageStyle style,
        boolean maximized) {
    try {//from  w  ww.  jav a 2 s . c o m
        Stage st = new Stage();
        stage = (Stage) lb.getScene().getWindow();
        FXMLLoader root = new FXMLLoader(getClass().getResource(load));

        Scene scene = new Scene(root.load());
        st.initStyle(style);
        st.setResizable(resize);
        st.setMaximized(maximized);
        st.setTitle(judul);
        st.setScene(scene);
        ApplicationContext appContex = config.getInstance().getApplicationContext();
        Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
        st.getIcons().add(new Image(resource.getURI().toString()));
        st.show();
        stage.close();
        return root.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);// ww w .j a  v  a 2  s . co m
    stage.setHeight(180);

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

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

    label1.setLabelFor(hbox);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("ComboBoxSample");
    Scene scene = new Scene(new Group(), 450, 250);

    CubicCurve cubic = new CubicCurve();
    cubic.setStartX(0.0f);/*from   w w  w . j a  va 2 s.c om*/
    cubic.setStartY(50.0f);
    cubic.setControlX1(25.0f);
    cubic.setControlY1(0.0f);
    cubic.setControlX2(75.0f);
    cubic.setControlY2(100.0f);
    cubic.setEndX(100.0f);
    cubic.setEndY(50.0f);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(cubic);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);/*from   www.ja v  a2 s . co  m*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    Path path = new Path();
    path.getElements().add(new MoveTo(50.0f, 0.0f));
    VLineTo vlt = new VLineTo(50.0f);
    vlt.setY(.7);
    path.getElements().add(vlt);

    System.out.println(vlt.yProperty());

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

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