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

    TilePane tile = new TilePane();

    tile.setHgap(8);//from   w  ww. j a v  a2s. co m
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setTileAlignment(Pos.BASELINE_CENTER);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.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.web("0x0000FF", 1.0));

    Text text = new Text(50, 100, "JavaFX 2.0 from Java2s.com");
    Font sanSerif = Font.font("Dialog", 30);
    text.setFont(sanSerif);//from  w  w  w .  j  a  va 2s. c  om
    text.setFill(Color.RED);
    root.getChildren().add(text);

    BoxBlur bb = new BoxBlur();
    bb.setWidth(15);
    bb.setHeight(15);
    bb.setIterations(3);

    text.setEffect(bb);

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

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

/**
 * Handles click events on the table. When clicking on the "image" or
 * "audio" column of a word, it opens a new stage for editing them.
 *
 * @param event// w  w w .j a v a 2  s  .  c o m
 */
private void tableClick(MouseEvent event) {
    if (!rows.isEmpty() && !tableView.getSelectionModel().getSelectedCells().isEmpty()) {
        TablePosition position = tableView.getSelectionModel().getSelectedCells().get(0);
        if (colImage.equals(position.getTableColumn())) {
            int index = position.getRow();
            RowForCard row = (RowForCard) sortedRows.get(index);
            Image currentImage = row.getImageView().getImage();
            ImagePopup imagePopup = new ImagePopup(currentImage);
            Stage stage = new Stage();
            stage.setScene(new SceneStyler().createScene(imagePopup, SceneStyler.Style.TOPIC_LIST));
            stage.setTitle(Messages.msg("form.set_image_of_word", row.getTxtWord().getText()));
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initOwner(tableView.getScene().getWindow());
            stage.setResizable(false);
            tableView.getSelectionModel().clearSelection();

            stage.showAndWait();
            if (imagePopup.isOk()) {
                Image rowImage = imagePopup.getFinalImage();
                File cardImageFile = imagePopup.getFile();
                if (rowImage != null && cardImageFile != null) {
                    row.setImageFile(cardImageFile);
                    row.setImage(rowImage);
                } else if (rowImage == null) {
                    row.setImage(DefaultImage.getInstance());
                }
            }
        } else if (colAudio.equals(position.getTableColumn())) {
            int index = position.getRow();
            RowForCard row = (RowForCard) sortedRows.get(index);
            AudioPopup audioPopup = new AudioPopup(row.getAudioIcon().getAudio());
            Stage stage = new Stage();
            stage.setScene(new SceneStyler().createScene(audioPopup, SceneStyler.Style.TOPIC_LIST));
            stage.setTitle(Messages.msg("form.set_audio_of_word", row.getTxtWord().getText()));
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initOwner(tableView.getScene().getWindow());
            stage.setResizable(false);
            tableView.getSelectionModel().clearSelection();

            stage.showAndWait();
            if (audioPopup.isOk()) {
                File audioFile = audioPopup.getFile();
                row.setAudioFile(audioFile);
                row.setAudio(audioPopup.getFinalAudio());
            }
        }
    }
}

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);//from ww  w  . j  ava 2  s.  c o m
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setOrientation(Orientation.HORIZONTAL);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);//w  ww.  ja  va 2s. co  m
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setAllowIndeterminate(true);

    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);//from w w w  .j  ava  2s . c  om
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    System.out.println(tile.tileWidthProperty());

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);/*from ww w  .  j  a  va2 s . co  m*/
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

    System.out.println(TilePane.getMargin(hbox));

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);//from   w w  w .  j  a  va  2s  . c  om
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    System.out.println(tile.tileHeightProperty());

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    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 w  w  w.  j  av a2 s.  c o 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);
    System.out.println(label1.getLabelFor());
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);/*from   ww  w  .  j  a  va 2 s.  com*/
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

    System.out.println(tile.alignmentProperty());

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