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

The following examples show how to use javafx.scene.layout.HBox#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: HBoxSample.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    HBox hbox = new HBox(3);
    hbox.setAlignment(Pos.CENTER);

    Rectangle rectangle = new Rectangle(70, 25, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    hbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(14, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 14, Color.web("#349b00"));

    hbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, hbox);

    return new Group(sp);
}
 
Example 2
Source File: HBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    HBox hbox = new HBox(3);
    hbox.setAlignment(Pos.CENTER);

    Rectangle rectangle = new Rectangle(70, 25, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    hbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(14, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 14, Color.web("#349b00"));

    hbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, hbox);

    return new Group(sp);
}
 
Example 3
Source File: Board.java    From util4j with Apache License 2.0 6 votes vote down vote up
private void createGrid() {
    
    gridOperator.traverseGrid((i,j)->{
        gridGroup.getChildren().add(createCell(i, j));
        return 0;
    });

    gridGroup.getStyleClass().add("game-grid");
    gridGroup.setManaged(false);
    gridGroup.setLayoutX(BORDER_WIDTH);
    gridGroup.setLayoutY(BORDER_WIDTH);

    HBox hBottom = new HBox();
    hBottom.getStyleClass().add("game-backGrid");
    hBottom.setMinSize(gridWidth, gridWidth);
    hBottom.setPrefSize(gridWidth, gridWidth);
    hBottom.setMaxSize(gridWidth, gridWidth);
    
    // Clip hBottom to keep the dropshadow effects within the hBottom
    Rectangle rect = new Rectangle(gridWidth, gridWidth);
    hBottom.setClip(rect);
    hBottom.getChildren().add(gridGroup);
    
    vGame.getChildren().add(hBottom);
}
 
Example 4
Source File: AcqButtonTests.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    HBox root = new HBox();
    root.setPrefSize(640, 480);

    root.getChildren().addAll(getAcquisitionBarTest(true), getAcquisitionBarTest(false));

    Scene scene = new Scene(root, 800, 600);
    primaryStage.setScene(scene);
    primaryStage.setTitle(AcqButtonTests.class.getSimpleName());
    primaryStage.show();
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
}
 
Example 5
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    regularFont = Fonts.latoRegular(10);
    lightFont   = Fonts.latoLight(10);

    itemText = new Text("NAME");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(regularFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    vBoxTitles = new VBox(2, itemText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    vBoxValues = new VBox(2, itemNameText);

    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example 6
Source File: Board.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
private void createGrid() {

        for (int i = 0; i < gridOperator.getGridSize(); i++) {
            for (int j = 0; j < gridOperator.getGridSize(); j++) {
                gridGroup.getChildren().add(createCell(i, j));
            }
        }

        gridGroup.getStyleClass().add("game-grid");
        gridGroup.setManaged(false);
        gridGroup.setLayoutX(BORDER_WIDTH);
        gridGroup.setLayoutY(BORDER_WIDTH);

        HBox hBottom = new HBox();
        hBottom.getStyleClass().add("game-backGrid");
        hBottom.setMinSize(gridWidth, gridWidth);
        hBottom.setPrefSize(gridWidth, gridWidth);
        hBottom.setMaxSize(gridWidth, gridWidth);

        // Clip hBottom to keep the dropshadow effects within the hBottom
        Rectangle rect = new Rectangle(gridWidth, gridWidth);
        hBottom.setClip(rect);
        hBottom.getChildren().add(gridGroup);

        vGame.getChildren().add(hBottom);

    }
 
Example 7
Source File: InfoPopup.java    From charts with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    Font regularFont = Fonts.latoRegular(10);
    Font lightFont   = Fonts.latoLight(10);

    seriesText = new Text("SERIES");
    seriesText.setFill(_textColor);
    seriesText.setFont(regularFont);

    seriesNameText = new Text("-");
    seriesNameText.setFill(_textColor);
    seriesNameText.setFont(lightFont);

    seriesSumText = new Text("SUM");
    seriesSumText.setFill(_textColor);
    seriesSumText.setFont(regularFont);

    seriesValueText = new Text("-");
    seriesValueText.setFill(_textColor);
    seriesValueText.setFont(lightFont);

    itemText = new Text("ITEM");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(lightFont);

    valueText = new Text("VALUE");
    valueText.setFill(_textColor);
    valueText.setFont(regularFont);

    itemValueText = new Text("-");
    itemValueText.setFill(_textColor);
    itemValueText.setFont(lightFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    VBox vBoxTitles = new VBox(2, seriesText, seriesSumText, itemText, valueText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    VBox vBoxValues = new VBox(2, seriesNameText, seriesValueText, itemNameText, itemValueText);
    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example 8
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Creates the earth time bar
	 */
	public void createEarthTimeBar() {

		if (masterClock == null)
			masterClock = sim.getMasterClock();

		if (earthClock == null)
			earthClock = masterClock.getEarthClock();

		datePickerFX = new JFXDatePicker();
		datePickerFX.setValue(earthClock.getLocalDate());
		datePickerFX.setEditable(false);
		// datePickerFX.setDefaultColor(Color.valueOf("#065185"));
		// datePickerFX.setOverLay(true);
		datePickerFX.setShowWeekNumbers(true);
		datePickerFX.setPromptText("Earth Date");
		datePickerFX.setId("earth-time");

		setQuickToolTip(datePickerFX, "Earth Date");

		timePickerFX = new JFXTimePicker();
		timePickerFX.setValue(earthClock.getLocalTime());

		timePickerFX.setEditable(false);
		// timePickerFX.setDefaultColor(Color.valueOf("#065185"));
		// blueDatePicker.setOverLay(true);
		timePickerFX.setPromptText("Earth Time");
		timePickerFX.setId("earth-time");
//		timePickerFX.set24HourView(true);
		
		setQuickToolTip(timePickerFX, "Earth Time in UTC");

		HBox box = new HBox(5, datePickerFX, timePickerFX);

		earthTimeBox = new HBox(box);
		earthTimeBox.setId("earth-time-box");
		earthTimeBox.setAlignment(Pos.CENTER);

		if (OS.contains("linux")) {
			earthTimeBox.setPrefSize(50, 25); // 270
			datePickerFX.setPrefSize(25, 25);// 160, 29);
			timePickerFX.setPrefSize(25, 25);// 140, 29);
		} else if (OS.contains("mac")) {
			earthTimeBox.setPrefSize(50, 23); // 230
			datePickerFX.setPrefSize(23, 23);
			timePickerFX.setPrefSize(23, 23);
		} else {
			earthTimeBox.setPrefSize(50, 25);
			datePickerFX.setPrefSize(25, 25);// 130, 25);
			timePickerFX.setPrefSize(25, 25);// 110, 25);
		}

	}