Java Code Examples for javafx.scene.layout.VBox#setPrefSize()

The following examples show how to use javafx.scene.layout.VBox#setPrefSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 8 votes vote down vote up
/**
 * Creates the pause box to be displayed on the root pane.
 * 
 * @return VBox
 */
private VBox createPausePaneContent() {
	VBox vbox = new VBox();
	vbox.setPrefSize(150, 150);

	Label label = new Label("||");
	label.setAlignment(Pos.CENTER);
	label.setPadding(new Insets(10));
	label.setStyle("-fx-font-size: 48px; -fx-text-fill: cyan;");
	// label.setMaxWidth(250);
	label.setWrapText(true);

	Label label1 = new Label("ESC to resume");
	label1.setAlignment(Pos.CENTER);
	label1.setPadding(new Insets(2));
	label1.setStyle(" -fx-font: bold 11pt 'Corbel'; -fx-text-fill: cyan;");
	vbox.getChildren().addAll(label, label1);
	vbox.setAlignment(Pos.CENTER);

	return vbox;
}
 
Example 2
Source File: VBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    VBox vbox = new VBox(3);
    vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(5, 5, 5, 5));

    Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
    Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));

    vbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, vbox);
    return new Group(sp);
}
 
Example 3
Source File: VBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    VBox vbox = new VBox(3);
    vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(5, 5, 5, 5));

    Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
    Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));

    vbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, vbox);
    return new Group(sp);
}
 
Example 4
Source File: FxDisplay.java    From testing-video with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent pane = root.get();

    double width = size.width;
    double height = size.height;

    VBox box = new VBox(pane);
    VBox.setVgrow(pane, ALWAYS);
    box.setMinSize(width, height);
    box.setPrefSize(width, height);
    box.setMaxSize(width, height);

    box.setBackground(new Background(new BackgroundFill(fill, null, null)));

    var scroll = new ScrollPane(box);
    var scene = new Scene(scroll);

    stage.setScene(scene);
    stage.show();
}
 
Example 5
Source File: ADCStandaloneProgressWindow.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public ADCStandaloneProgressWindow(@NotNull Stage stage) {
	this.stage = stage;

	stage.getIcons().add(new Image("/com/armadialogcreator/pwindow/app.png"));

	root = new VBox(5);
	stage.setScene(new Scene(new StackPane(root)));
	stage.setResizable(false);

	root.setPrefSize(720, 360);
	root.setAlignment(Pos.CENTER);
	root.setPadding(new Insets(10));

	root.getChildren().add(new ImageView("/com/armadialogcreator/pwindow/adc_title.png"));

	progressBar.setMaxWidth(Double.MAX_VALUE);
	root.getChildren().add(progressBar);
	root.getChildren().add(lblStatus);
	lblError.setTextFill(Color.RED);
	root.getChildren().add(lblError);
}
 
Example 6
Source File: RPGApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    VBox root = new VBox(10);
    root.setPrefSize(800, 600);
    root.setPadding(new Insets(15));

    Button btnAttack = new Button("ATTACK");
    btnAttack.setOnAction(e -> makeMove(Action.ATTACK));

    Button btnCharge = new Button("CHARGE");
    btnCharge.setOnAction(e -> makeMove(Action.CHARGE));

    Button btnBlock = new Button("BLOCK");
    btnBlock.setOnAction(e -> makeMove(Action.BLOCK));

    output.setPrefHeight(450);
    output.setFont(Font.font(26));

    updateInfo();

    root.getChildren().addAll(btnAttack, btnCharge, btnBlock, output);

    return root;
}
 
Example 7
Source File: DownloaderApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    VBox root = new VBox();
    root.setPrefSize(400, 600);

    TextField fieldURL = new TextField();
    root.getChildren().addAll(fieldURL);

    fieldURL.setOnAction(event -> {
        Task<Void> task = new DownloadTask(fieldURL.getText());
        ProgressBar progressBar = new ProgressBar();
        progressBar.setPrefWidth(350);
        progressBar.progressProperty().bind(task.progressProperty());
        root.getChildren().add(progressBar);

        fieldURL.clear();

        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
    });

    return root;
}
 
Example 8
Source File: DialogsApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    VBox box = new VBox();
    box.setPrefSize(800, 600);
    Button btn1 = new Button("Open JavaFX dialog");
    btn1.setOnAction(e -> {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setHeaderText("Header");
        alert.setContentText("Content");
        alert.show();
    });

    Button btn2 = new Button("Open Custom dialog");
    btn2.setOnAction(e -> {
        CustomDialog dialog = new CustomDialog("Header", "Content");
        dialog.openDialog();
    });

    box.getChildren().addAll(btn1, btn2);

    return box;
}
 
Example 9
Source File: ChatApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    messages.setFont(Font.font(72));
    messages.setPrefHeight(550);
    TextField input = new TextField();
    input.setOnAction(event -> {
        String message = isServer ? "Server: " : "Client: ";
        message += input.getText();
        input.clear();

        messages.appendText(message + "\n");

        try {
            connection.send(message);
        }
        catch (Exception e) {
            messages.appendText("Failed to send\n");
        }
    });

    VBox root = new VBox(20, messages, input);
    root.setPrefSize(600, 600);
    return root;
}
 
Example 10
Source File: GenerateCodeDialog.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
private void selectPlugin(List<CodePluginItem> pluginItems, String changeWhat, Consumer<CodePluginItem> eventHandler) {

        Popup popup = new Popup();
        List<UICodePluginItem> listOfComponents = pluginItems.stream()
                .map(display -> {
                    var it = new UICodePluginItem(manager, display, SELECT, item -> {
                        popup.hide();
                        eventHandler.accept(item);
                    });
                    it.setId("sel-" + display.getId());

                    return it;
                })
                .collect(Collectors.toList());

        VBox vbox = new VBox(5);
        addTitleLabel(vbox, "Select the " + changeWhat + " to use:");
        vbox.getChildren().addAll(listOfComponents);
        vbox.setPrefSize(700, 600);

        BorderPane pane = new BorderPane();
        pane.setCenter(vbox);
        vbox.getStyleClass().add("popupWindow");

        popup.getContent().add(pane);
        popup.setAutoHide(true);
        popup.setOnAutoHide(event -> popup.hide());
        popup.setHideOnEscape(true);
        popup.show(dialogStage);
    }
 
Example 11
Source File: GCApp.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    VBox root = new VBox(10);
    root.setPrefSize(800, 600);
    root.setPadding(new Insets(50, 50, 50, 50));

    root.getChildren().addAll(makeToolbar(),
            new Label("EDEN"), edenSpace,
            new Label("S1"), s1Space,
            new Label("S2"), s2Space,
            new Label("OLD"), oldSpace);
    return root;
}
 
Example 12
Source File: AboutLogFXView.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
VBox createNode() {
    VBox contents = new VBox( 25 );
    contents.setPrefSize( 500, 300 );
    contents.setAlignment( Pos.CENTER );
    contents.getStylesheets().add( "css/about.css" );

    HBox textBox = new HBox( 0 );
    textBox.setPrefWidth( 500 );
    textBox.setAlignment( Pos.CENTER );
    Text logText = new Text( "Log" );
    logText.setId( "logfx-text-log" );
    Text fxText = new Text( "FX" );
    fxText.setId( "logfx-text-fx" );
    textBox.getChildren().addAll( logText, fxText );

    VBox smallText = new VBox( 10 );
    smallText.setPrefWidth( 500 );
    smallText.setAlignment( Pos.CENTER );
    Text version = new Text( "Version " + Constants.LOGFX_VERSION );
    Text byRenato = new Text( "Copyright Renato Athaydes, 2017. All rights reserved." );
    Text license = new Text( "Licensed under the GPLv3 License." );
    Hyperlink link = new Hyperlink( "https://github.com/renatoathaydes/LogFX" );
    link.setOnAction( ( event ) -> hostServices.showDocument( link.getText() ) );
    smallText.getChildren().addAll( version, byRenato, link, license );

    contents.getChildren().addAll( textBox, smallText );

    return contents;
}
 
Example 13
Source File: StepRepresentationBrowse.java    From phoenicis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Node dragPane() {
    final Text textLabel = new Text(textToShow);
    final Text dragLabel = new Text(tr("Click or drag-and-drop file here"));
    textLabel.getStyleClass().add("boldLabel");
    dragLabel.getStyleClass().addAll("normalLabel");

    final VBox dragTarget = new VBox();
    dragTarget.getChildren().addAll(textLabel, dragLabel);
    dragTarget.setOnDragOver(event -> {
        if (event.getGestureSource() != dragTarget && event.getDragboard().hasFiles()) {
            event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
        }
        event.consume();
    });

    dragTarget.setOnDragDropped(event -> {
        Dragboard db = event.getDragboard();
        boolean success = false;
        if (db.hasFiles()) {
            this.selectFile(db.getFiles().get(0));
            success = true;
        }

        event.setDropCompleted(success);

        event.consume();
    });

    dragTarget.setPrefSize(660, 308);
    dragTarget.getStyleClass().addAll("dragAndDropBox");

    dragTarget.setOnMouseClicked(event -> {
        final FileChooser fileChooser = new FileChooser();
        if (extensions != null) {
            fileChooser
                    .setSelectedExtensionFilter(
                            new FileChooser.ExtensionFilter(tr("Allowed file types"), extensions));
        }
        fileChooser.setInitialDirectory(browseDirectory);

        File dialogResult = fileChooser.showOpenDialog(null);
        if (dialogResult != null) {
            selectFile(dialogResult);
        }
    });

    return dragTarget;
}