Java 类javafx.scene.SceneBuilder 实例源码

项目:code-similarity    文件:JfxVideo.java   
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("JavaFX Video");
    final List<String> args = getParameters().getRaw();

    String url = args.size() > 0 ?
        args.get(args.size() - 1) :
            "http://www.mediacollege.com/" +
            "video-gallery/testclips/20051210-w50s.flv";
    Media media = new Media(url);

    MediaPlayer player = new MediaPlayer(media);
    player.play();

    MediaView view = new MediaView(player);
    Group root = new Group();
    root.getChildren().add(view);
    Scene scene = SceneBuilder.create().
            width(360).height(288).
            root(root).
            fill(Color.WHITE).
            build();
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:fxpoc    文件:SampleUICommand.java   
/**
 * {@inheritDoc}
 */
@Override
protected void execute(final Wave wave) {

    LOGGER.info("Display a pop up from JAT");

    final Stage s = StageBuilder.create()
            .title("Sample Ui Command Test")
            .style(StageStyle.DECORATED)
            .scene(SceneBuilder.create()
                    .root(LabelBuilder.create().text("Run into JAT").build())
                    .build())

            .build();

    s.show();
    // Sample for popup => Attach owner !!!
    // getLocalFacade().getGlobalFacade().getApplication().getStage()
}
项目:javafx-demos    文件:ZoomApp.java   
@Override
public void start(Stage stage) throws Exception {

    final Group innerGroup = createSixRectangles();
    final Group outerGroup = new Group(innerGroup);

    final ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(outerGroup);
    scrollPane.setOnScroll(new ZoomHandler(innerGroup));

    StackPane stackPane = new StackPane();
    stackPane.getChildren().add(scrollPane);

    Scene scene = SceneBuilder.create()
            .width(WINDOW_WIDTH)
            .height(WINDOW_HEIGHT)
            .root(stackPane)
            .build();

    stage.setScene(scene);
    stage.show();
}
项目:simplejavayoutubeuploader    文件:QueueUploadCellRenderer.java   
@Override
public void handle(final ActionEvent event) {
    if (item.getStatus().isRunning()) {
        return;
    }
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource("/de/chaosfisch/uploader/view/ConfirmDialog.fxml"), resources);
        final ConfirmDialogController controller = result.getController();
        controller.setTitle(resources.getString("dialog.removeupload.title"));
        controller.setMessage(resources.getString("dialog.removeupload.message"));

        final Parent parent = result.getRoot();
        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        stage.requestFocus();
        if (controller.ask()) {
            uploadService.delete(upload);
        }
    } catch (final IOException e) {
        logger.error("Couldn't load ConfirmDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:QueueUploadCellRenderer.java   
@Override
public void handle(final ActionEvent arg0) {
    if (!item.getStatus().isRunning()) {
        return;
    }

    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource("/de/chaosfisch/uploader/view/ConfirmDialog.fxml"), resources);
        final ConfirmDialogController controller = result.getController();
        controller.setTitle(resources.getString("dialog.abortupload.title"));
        controller.setMessage(resources.getString("dialog.abortupload.message"));

        final Parent parent = result.getRoot();
        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        stage.requestFocus();
        if (controller.ask()) {
            uploadService.abort(item);
        }
    } catch (final IOException e) {
        logger.error("Couldn't load ConfirmDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:DialogHelper.java   
public void showPlaylistAddDialog() {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource(
                "/de/chaosfisch/uploader/view/PlaylistAddDialog.fxml"), resources);
        final Parent parent = result.getRoot();

        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.requestFocus();
        stage.showAndWait();
    } catch (final IOException e) {
        logger.error("Couldn't load PlaylistAddDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:DialogHelper.java   
public void showErrorDialog(final String title, final String message) {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource(
                "/de/chaosfisch/uploader/view/ErrorDialog.fxml"), resources);
        final ErrorDialogController controller = result.getController();
        controller.setTitle(title);
        controller.setMessage(message);

        final Parent parent = result.getRoot();
        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        stage.requestFocus();
    } catch (final IOException e) {
        logger.error("Couldn't load ConfirmDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:DialogHelper.java   
public void showInputDialog(final String title, final String input, final Callback callback, final boolean blocking) {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource(
                "/de/chaosfisch/uploader/view/InputDialog.fxml"), resources);
        final Parent parent = result.getRoot();
        final InputDialogController controller = result.getController();
        controller.setTitle(resources.containsKey(title) ? resources.getString(title) : title);
        controller.setInput(resources.containsKey(input) ? resources.getString(input) : input);
        controller.setCallback(callback);

        final Scene scene = SceneBuilder.create().fill(Color.TRANSPARENT).root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        if (blocking) {
            stage.showAndWait();
        } else {
            stage.show();
        }
        stage.requestFocus();
    } catch (final IOException e) {
        logger.error("Couldn't load InputDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:DialogHelper.java   
public void showAccountPermissionsDialog(final Account account) {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource(
                "/de/chaosfisch/uploader/view/AccountAddDialog.fxml"), resources);
        final Parent parent = result.getRoot();
        ((AccountAddDialogController) result.getController()).initAuth(account);

        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.DECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.setResizable(true);
        stage.requestFocus();
        stage.showAndWait();
    } catch (final Exception e) {
        logger.error("Couldn't load AccountAddDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:QueueCommandController.java   
@FXML
void startQueue(final ActionEvent event) {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource("/de/chaosfisch/uploader/view/ConfirmDialog.fxml"), resources);
        final ConfirmDialogController controller = result.getController();
        controller.setTitle(resources.getString("dialog.youtubetos.title"));
        controller.setMessage(resources.getString("dialog.youtubetos.message"));

        final Parent parent = result.getRoot();
        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        stage.requestFocus();
        if (controller.ask()) {
            uploadService.startUploading();
        }
    } catch (final IOException e) {
        logger.error("Couldn't load ConfirmDialog", e);
    }
}
项目:simplejavayoutubeuploader    文件:GUIUploader.java   
@Override
public void handle(final WindowEvent event) {
    try {
        final GuiceFXMLLoader.Result result = fxmlLoader.load(getClass().getResource("/de/chaosfisch/uploader/view/ConfirmDialog.fxml"), resources);
        final ConfirmDialogController controller = result.getController();
        controller.setTitle(resources.getString("dialog.exitapplication.title"));
        controller.setMessage(resources.getString("dialog.exitapplication.message"));

        final Parent parent = result.getRoot();
        final Scene scene = SceneBuilder.create().root(parent).build();
        final Stage stage = StageBuilder.create().scene(scene).build();
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        stage.requestFocus();
        if (!controller.ask()) {
            event.consume();
        } else {
            Platform.exit();
        }
    } catch (final IOException e) {
        LOGGER.error("Couldn't load ConfirmDialog", e);
    }
}
项目:btc1k    文件:App.java   
@Override
public void start (Stage primaryStage) throws Exception
{
    instance = this;

    restClient = new RestClient (SERVER_URI);
    vault = new Vault (fetchKeys ());

    FXMLLoader loader = new FXMLLoader (App.class.getResource ("main.fxml"));
    Parent root = (Parent) loader.load ();

    Scene scene = SceneBuilder.create ()
            .root (root)
            .stylesheets ("com/bitsofproof/btc1k/fx/main.css")
            .build ();

    StageBuilder.create ()
            .title ("BTC-1K")
            .scene (scene)
            .minWidth (600)
            .minHeight (600)
            .applyTo (primaryStage);

    primaryStage.show ();

}
项目:JavaFX    文件:SingleClassNoXmlBallGame.java   
private void initGui(final Stage stage) {
    Scene scene = SceneBuilder.create().width(500).height(530)
            .fill(Color.GRAY).root(area).build();
    initBoxes();
    stage.setScene(scene);
    stage.setTitle("hasCode.com - Java FX 2 Ball Game Tutorial");
    stage.getIcons().add(ICON);
    scene.getStylesheets().add(STYLESHEET_FILE);
    stage.show();
}
项目:JavaFX    文件:BallGame.java   
private void initGui(Stage stage) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource(VIEW_GAME));
    Scene scene = SceneBuilder.create().root(root).width(500).height(530)
            .fill(Color.GRAY).build();
    scene.getStylesheets().add(STYLESHEET_FILE);
    stage.setScene(scene);
    stage.setTitle("hasCo de.com - Java FX 2 Ball Game Tutorial");
    stage.getIcons().add(ICON);
    stage.show();
}
项目:mars-sim    文件:Scroll2.java   
@Override
public void start(Stage stage) {

  String message = 
    "Earthrise at Christmas: " +
    "[Forty] years ago this Christmas, a turbulent world " +
    "looked to the heavens for a unique view of our home "  +
    "planet. This photo of Earthrise over the lunar horizon " +
    "was taken by the Apollo 8 crew in December 1968, showing " +
    "Earth for the first time as it appears from deep space. " +
    "Astronauts Frank Borman, Jim Lovell and William Anders " +
    "had become the first humans to leave Earth orbit, " +
    "entering lunar orbit on Christmas Eve. In a historic live " +
    "broadcast that night, the crew took turns reading from " +
    "the Book of Genesis, closing with a holiday wish from " +
    "Commander Borman: \"We close with good night, good luck, " +
    "a Merry Christmas, and God bless all of you -- all of " +
    "you on the good Earth.\"";

  // Reference to the Text
  Text textRef = TextBuilder.create()
    .layoutY(100)
    .textOrigin(VPos.TOP)
    .textAlignment(TextAlignment.JUSTIFY)
    .wrappingWidth(400)
    .text(message)
    .fill(Color.rgb(187, 195, 107))
    .font(Font.font("SansSerif", FontWeight.BOLD, 24))
    .build();

   // Provides the animated scrolling behavior for the text
  TranslateTransition transTransition = TranslateTransitionBuilder.create()
    .duration(new Duration(75000))
    .node(textRef)
    .toY(-820)
    .interpolator(Interpolator.LINEAR)
    .cycleCount(Timeline.INDEFINITE)
    .build();

  Scene scene  = SceneBuilder.create()
    .width(516)
    .height(387)
    .root(
      GroupBuilder.create()
        .children(
          ImageViewBuilder.create()
            .image(new Image("http://projavafx.com/images/earthrise.jpg"))
            .build(),
          ScrollPaneBuilder.create()
            .layoutX(50)
            .layoutY(100)
            .prefWidth(440)
            .prefHeight(200)
            .hbarPolicy(ScrollBarPolicy.NEVER)
            .vbarPolicy(ScrollBarPolicy.NEVER)
            .pannable(true)
            .content(textRef)
            .style("-fx-background-color: transparent;")
            .build()
        )
        .build()
    )
    .build();

  stage.setScene(scene);
  stage.setTitle("Hello Earthrise");
  stage.show();

  // Start the text animation
  transTransition.play();
}
项目:javafx-demos    文件:TriangleArea.java   
@Override public void start(Stage stage) {
  final Group root;
  Scene scene = SceneBuilder.create()
    .width(500).height(500)
    .fill(Color.WHITE)
    .root(root = GroupBuilder.create()
      .children(RectangleBuilder.create()
        .layoutX(5).layoutY(5)
        .width(490).height(490)
        .fill(Color.LIGHTSKYBLUE)
        .onMouseClicked(new EventHandler<MouseEvent>() {
          // Eventhandler for mouse click event
          @Override public void handle(MouseEvent e) {
            if (clickcount > 2) { initialize(); }
            for (int j = clickcount; j < 3; j++) {
              org_x[j].set(e.getSceneX());
              org_y[j].set(e.getSceneY());
            }
            clickcount++;
          }
        }).build(),
      // line for x-axis through the Origin
      LineBuilder.create()
        .startX(5).startY(490)
        .endX(495).endY(490)
        .build(),
      // Line for y-axis through the Origin
      LineBuilder.create()
        .startX(10).startY(5)
        .endX(10).endY(495)
        .build(),
      // grid horizontal lines which interval is of 1cm
      a_x_l[0], a_x_l[1], a_x_l[2], a_x_l[3],
      a_x_l[4], a_x_l[5], a_x_l[6], a_x_l[7],
      a_x_l[8], a_x_l[9], a_x_l[10], a_x_l[11],
      // grid vertical lines which interval is of 1cm
      a_y_l[0], a_y_l[1], a_y_l[2], a_y_l[3],
      a_y_l[4], a_y_l[5], a_y_l[6], a_y_l[7],
      a_y_l[8], a_y_l[9], a_y_l[10], a_y_l[11],
      // Sides
      l[0], l[1], l[2],
      // Vertices
      c[0], c[1], c[2],
      // the printing space of the coordinates and
      // the area of triangle
      HBoxBuilder.create()
        .layoutX(10)
        .padding(new Insets(10, 10, 10, 10)).spacing(3)
        .alignment(Pos.BOTTOM_CENTER)
        .children(
          LabelBuilder.create().text("A(").build(),
          tx[0],
          LabelBuilder.create().text(",").build(),
          ty[0],
          LabelBuilder.create().text("),").build(),
          LabelBuilder.create().text("B(").build(),
          tx[1],
           LabelBuilder.create().text(",").build(),
          ty[1],
          LabelBuilder.create().text("),").build(),
          LabelBuilder.create().text("C(").build(),
          tx[2],
          LabelBuilder.create().text(",").build(),
          ty[2],
          LabelBuilder.create().text(") ⇒ ").build(),
          area_Label
        ).build()
    ).build()
  ).build();

  stage.setTitle("Triangle Area");
  stage.setScene(scene);
  stage.show();
}