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

The following examples show how to use javafx.scene.layout.HBox#setPrefHeight() . 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: ClientController.java    From ChatFX with MIT License 6 votes vote down vote up
private void addMsg(String msg, boolean senderIsServer) {
    Label lbl = new Label(msg);
    lbl.setStyle("-fx-font-size: 16px;"
            + "-fx-background-color: #" + (senderIsServer ? "B00020" : "2196f3") + ";"
            + "-fx-text-fill: #FFF;"
            + "-fx-background-radius:25;"
            + "-fx-padding: 10px;");
    lbl.setWrapText(true);
    lbl.setMaxWidth(400);
    
    HBox container = new HBox();
    if(senderIsServer) {
        container.getChildren().add(new ImageView(new Image("/images/server-48px.png")));
        container.setAlignment(Pos.CENTER_LEFT);
        container.setSpacing(10);
        container.setPadding(new Insets(0, 10, 0, 0));
    } else {
        container.setAlignment(Pos.CENTER_RIGHT);
        container.setPadding(new Insets(0, 10, 0, 10));
    }
    container.getChildren().add(lbl);
    container.setPrefHeight(40);

    msgNodes.getItems().add(container);
}
 
Example 2
Source File: ChatController.java    From ChatFX with MIT License 6 votes vote down vote up
private void addMsg(String msg, boolean senderIsRobot) {
    Label lbl = new Label(msg);
    lbl.setStyle("-fx-font-size: 16px;"
            + "-fx-background-color: #" + ((senderIsRobot) ? "B00020" : "2196f3") + ";"
            + "-fx-text-fill: #FFF;"
            + "-fx-background-radius:25;"
            + "-fx-padding: 10px;");
    lbl.setWrapText(true);
    lbl.setMaxWidth(400);
    HBox container = new HBox();
    container.setPrefHeight(40);
    container.setAlignment(Pos.CENTER_LEFT);
    container.setPadding(new Insets(0, 10, 0, 10));
    container.setSpacing(10);
    container.getChildren().add(lbl);

    msgNodes.getItems().add(container);
}
 
Example 3
Source File: ServerController.java    From ChatFX with MIT License 6 votes vote down vote up
private void addMsg(String msg, boolean senderIsServer) {
    Label lbl = new Label(msg);
    lbl.setStyle("-fx-font-size: 16px;"
            + "-fx-background-color: #" + (senderIsServer ? "B00020" : "2196f3") + ";"
            + "-fx-text-fill: #FFF;"
            + "-fx-background-radius:25;"
            + "-fx-padding: 10px;");
    lbl.setWrapText(true);
    lbl.setMaxWidth(400);
    
    HBox container = new HBox();
    if(!senderIsServer) {
        container.getChildren().add(new ImageView(new Image("/images/client-48px.png")));
        container.setAlignment(Pos.CENTER_LEFT);
        container.setSpacing(10);
        container.setPadding(new Insets(0, 10, 0, 0));
    } else {
        container.setAlignment(Pos.CENTER_RIGHT);
        container.setPadding(new Insets(0, 10, 0, 10));
    }
    container.getChildren().add(lbl);
    container.setPrefHeight(40);

    msgNodes.getItems().add(container);
}
 
Example 4
Source File: DisplayWindow.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private Node getMessageBar(VBox vbox) {
    HBox hb = new HBox(10);
    hb.setPrefHeight(32);
    hb.setStyle("-fx-padding: 0 5px 0 5px; -fx-background-color: " + Version._message_bg + ";");
    CheckBox cb = new CheckBox("Do Not Show Again");
    cb.setStyle("-fx-text-fill: " + Version._message_fg + ";-fx-fill: " + Version._message_fg + ";");
    Text b = FXUIUtils.getIconAsText("close");
    b.setOnMouseClicked((e) -> {
        JSONObject preferences = Preferences.instance().getSection("display");
        preferences.put("_doNotShowMessage", cb.isSelected());
        Preferences.instance().save("display");
        vbox.getChildren().remove(0);
    });
    Text t = new Text(Version._message);
    hb.setAlignment(Pos.CENTER_LEFT);
    HBox.setHgrow(t, Priority.ALWAYS);
    t.setStyle("-fx-fill: " + Version._message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold; -fx-font-family: Tahoma;");
    b.setStyle("-fx-fill: " + Version._message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold;");
    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    hb.getChildren().addAll(t, spacer, b);
    return hb;
}
 
Example 5
Source File: ImageCropperPaneFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
	this.setBackground("Resources/Images/Wallpaper/18.jpg");
	this.setTitle("分页");
	this.setWidth(440);
	this.setHeight(460);
	this.setCenter(rootPane);

	HBox box = new HBox();
	box.setPrefHeight(50);
	box.setMaxHeight(50);
	
	box.getChildren().add(button);
	rootPane.setTop(box);
	
	VBox vBox = new VBox();
	vBox.getChildren().add(mp);
	//vBox.getChildren().add(scrollPane);
	
	rootPane.setCenter(vBox);

	Image i=new	Image(getClass().getResource("/resources/common/images/cropper/CircleMask.png").toExternalForm());
	mp.setCoverImage(i);
	
	Image image = ImageBox.getImagePath("Resources/Temp/1.jpg");
	mp.setImage(image);
	rootPane.setPrefSize(120, 140);
	rootPane.setMaxSize(120, 140);
	mp.setMaxSize(120, 140);
	
	//imageView.setPreserveRatio(true);
	imagePane.getChildren().add(imageView);
	scrollPane.setContent(imagePane);
	scrollPane.setPrefSize(120, 140);
	rootPane.setBottom(scrollPane);
}
 
Example 6
Source File: DragDrop.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public StackPane createDragDropBox() {

	    	StackPane pane = new StackPane();

	        HBox hBox1 = new HBox();
	        hBox1.setPrefWidth(100);
	        hBox1.setPrefHeight(100);
	        hBox1.setStyle("-fx-border-color: green;"
	              + "-fx-border-width: 2;"
	              + "-fx-border-style: solid;");

	        HBox hBox2 = new HBox();
	        hBox2.setPrefWidth(100);
	        hBox2.setPrefHeight(100);
	        hBox2.setStyle("-fx-border-color: orange;"
	              + "-fx-border-width: 2;"
	              + "-fx-border-style: solid;");

	        //insertImage(new Image(getClass().getResourceAsStream("/images/MaleIcon.png")), hBox1);
	        //insertImage(new Image(getClass().getResourceAsStream("/images/FemaleIcon.png")), hBox2);
	        //insertImage(new Image(getClass().getResourceAsStream("/images/RobotIcon.png")), hBox1);

	        insertImage("bee32.png", hBox1);
	        insertImage("branch32.png", hBox1);
	        insertImage("carrot32.png", hBox1);
	        insertImage("ladybug32.png", hBox1);
	        insertImage("leaf32.png", hBox1);	        

	        //setupGestureTarget(hBox1);
	        setupGestureTarget(hBox2);
	        
	        VBox vBox = new VBox();
	        vBox.getChildren().addAll(hBox1, hBox2);
	        pane.getChildren().addAll(vBox);

	        return pane;
	    }
 
Example 7
Source File: MainController.java    From MusicPlayer with MIT License 5 votes vote down vote up
protected void interpolate(double frac) {
HBox cell = (HBox) playlistBox.getChildren().get(1);
if (frac < 0.5) {
	cell.setPrefHeight(frac * 100);
} else {
	cell.setPrefHeight(50);
	cell.setOpacity((frac - 0.5) * 2);
}
  }
 
Example 8
Source File: MilestonePickerDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private HBox createNewlyAssignedMilestoneBox() {
    HBox milestoneBox = new HBox();
    milestoneBox.setPrefWidth(140);
    milestoneBox.setPrefHeight(40);
    milestoneBox.setStyle("-fx-border-radius: 3;-fx-border-style: dotted;-fx-alignment:center");
    return milestoneBox;
}
 
Example 9
Source File: MilestonePickerDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private HBox createPreviouslyAssignedMilestoneBox() {
    HBox milestoneBox = new HBox();
    milestoneBox.setPrefWidth(120);
    milestoneBox.setPrefHeight(PREV_ASSIGNED_MILESTONE_HEIGHT);
    milestoneBox.setMaxHeight(PREV_ASSIGNED_MILESTONE_HEIGHT);
    milestoneBox.setStyle("-fx-border-radius: 3;-fx-border-style: dotted;-fx-alignment:center");
    return milestoneBox;
}
 
Example 10
Source File: GradeTreeItem.java    From PDF4Teachers with Apache License 2.0 4 votes vote down vote up
public HBox getEditGraphics(int width, ContextMenu menu){

        Region spacer = new Region();
        Text name = new Text();

        Text value = new Text();
        Text slash = new Text("/");
        Text total = new Text();

        HBox pane = new HBox();
        pane.setAlignment(Pos.CENTER);
        pane.setPrefHeight(18);
        pane.setStyle("-fx-padding: -6 -6 -6 0;"); // top - right - bottom - left

        name.textProperty().bind(core.nameProperty());

        HBox.setMargin(value, new Insets(0, 0, 0, 5));
        value.textProperty().bind(Bindings.createStringBinding(() -> (core.getValue() == -1 ? "?" : Main.format.format(core.getValue())), core.valueProperty()));

        HBox.setMargin(total, new Insets(0, 5, 0, 0));
        total.textProperty().bind(Bindings.createStringBinding(() -> Main.format.format(core.getTotal()), core.totalProperty()));

        // SETUP

        HBox.setHgrow(spacer, Priority.ALWAYS);

        gradeField.setText(core.getValue() == -1 ? "" : Main.format.format(core.getValue()));
        if(!isRoot() && getParent() != null){
            if(((GradeTreeItem) getParent()).isExistTwice(core.getName())) core.setName(core.getName() + "(1)");
        }

        if(hasSubGrade()){
            pane.getChildren().addAll(name, spacer, value, slash, total);
        }else{
            pane.getChildren().addAll(name, spacer, gradeField, slash, total);
            Platform.runLater(() -> {
                gradeField.requestFocus();
            });
        }

        pageContextMenu = menu;

        pane.setOnMouseEntered(e -> {
            gradeField.requestFocus();
        });
        pane.setPrefWidth(width);
        return pane;
    }
 
Example 11
Source File: ListItemPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {

		
		headImageView.setClip(headImageClip);

		StackPane headStackPane = new StackPane();
		headStackPane.setPadding(new Insets(12, 8, 12, 18));
		headStackPane.getChildren().add(headImageView);

		redLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);");

		StackPane redStackPane = new StackPane();
		redStackPane.getChildren().add(redImageView);
		redStackPane.getChildren().add(redLabel);

		HBox redHBox = new HBox();
		redHBox.setAlignment(Pos.TOP_RIGHT);
		redHBox.getChildren().add(redStackPane);
		
		VBox redVBox = new VBox();
		redVBox.setAlignment(Pos.TOP_RIGHT);
		redVBox.getChildren().add(redHBox);

		StackPane leftStackPane = new StackPane();

		leftStackPane.getChildren().add(headStackPane);
		leftStackPane.getChildren().add(redVBox);

		nameLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);-fx-font-size: 14px;");

		HBox nameHBox = new HBox();
		nameHBox.setAlignment(Pos.CENTER_LEFT);
		nameHBox.getChildren().add(nameLabel);

		VBox centerVBox = new VBox();
		centerVBox.setAlignment(Pos.CENTER_LEFT);
		centerVBox.getChildren().add(nameHBox);

		HBox lineHBox = new HBox();
		lineHBox.setPrefHeight(1);
		lineHBox.setStyle("-fx-background-color:#292c33;");

		borderPane.setLeft(leftStackPane);
		borderPane.setCenter(centerVBox);
		borderPane.setBottom(lineHBox);
		//this.getStyleClass().add("chat-item-pane");
		this.getChildren().add(borderPane);
	}
 
Example 12
Source File: ChatItemPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {

		headImageView.setClip(headImageClip);

		StackPane headStackPane = new StackPane();
		headStackPane.setPadding(new Insets(12, 8, 12, 18));
		headStackPane.getChildren().add(headImageView);

		redLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);");

		StackPane redStackPane = new StackPane();
		redStackPane.getChildren().add(redImageView);
		redStackPane.getChildren().add(redLabel);

		HBox redHBox = new HBox();
		redHBox.setAlignment(Pos.TOP_RIGHT);
		redHBox.getChildren().add(redStackPane);

		VBox redVBox = new VBox();
		redVBox.setAlignment(Pos.TOP_RIGHT);
		redVBox.getChildren().add(redHBox);

		StackPane leftStackPane = new StackPane();

		leftStackPane.getChildren().add(headStackPane);
		leftStackPane.getChildren().add(redVBox);

		nameLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);-fx-font-size: 14px;");

		HBox nameHBox = new HBox();
		nameHBox.getChildren().add(nameLabel);

		timeLabel.setStyle("-fx-text-fill:#666a77;");

		BorderPane nameBorderPane = new BorderPane();

		nameBorderPane.setCenter(nameHBox);
		nameBorderPane.setRight(timeLabel);

		textLabel.setStyle("-fx-text-fill:rgba(152, 152, 152, 1);");

		HBox textHBox = new HBox();
		textHBox.setAlignment(Pos.CENTER_LEFT);
		textHBox.getChildren().add(textLabel);

		VBox centerVBox = new VBox();
		centerVBox.setSpacing(5);
		centerVBox.setPadding(new Insets(10, 0, 0, 0));
		centerVBox.getChildren().add(nameBorderPane);
		centerVBox.getChildren().add(textHBox);

		HBox lineHBox = new HBox();
		lineHBox.setPrefHeight(0.5);
		lineHBox.setStyle("-fx-background-color:#292c33;");

		borderPane.setLeft(leftStackPane);
		borderPane.setCenter(centerVBox);
		borderPane.setBottom(lineHBox);
		// borderPane.getStyleClass().add("selected-button");
		// this.getStyleClass().add("chat-item-pane");
		this.getChildren().add(borderPane);
	}
 
Example 13
Source File: WritePaneFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void init() {
	this.setBackground("Resources/Images/Wallpaper/18.jpg");
	this.setTitle("登录");
	this.setWidth(440);
	this.setHeight(360);
	this.setCenter(rootPane);

	HBox topBox = new HBox();
	topBox.setStyle("-fx-background-color:#2cb1e0");
	topBox.setPrefHeight(30);

	insertImageButton.setFocusTraversable(false);
	fontFamilyComboBox.setFocusTraversable(false);
	button.setFocusTraversable(false);
	fontSizeA.setFocusTraversable(false);
	fontSizeD.setFocusTraversable(false);
	boldButton.setFocusTraversable(false);
	underlineButton.setFocusTraversable(false);
	italicButton.setFocusTraversable(false);
	htmlButton.setFocusTraversable(false);

	TilePane tilePane = new TilePane();
	tilePane.setPrefColumns(3); // preferred columns
	tilePane.setAlignment(Pos.CENTER);

	tilePane.getChildren().add(insertImageButton);
	tilePane.getChildren().add(button);
	tilePane.getChildren().add(colorPicker);
	tilePane.getChildren().add(fontSizeA);
	tilePane.getChildren().add(fontFamilyComboBox);
	tilePane.getChildren().add(fontSizeD);
	tilePane.getChildren().add(boldButton);
	tilePane.getChildren().add(underlineButton);
	tilePane.getChildren().add(italicButton);
	tilePane.getChildren().add(htmlButton);

	box.setStyle("-fx-background-color:rgba(255, 255, 255, 0.2)");
	box.getChildren().add(tilePane);
	box.getChildren().add(writePanel);
	box.getChildren().add(textArea);

	// comboBox.setItems("");
	ObservableList<String> fonts = new ObservableListWrapper<String>(new ArrayList<String>()); // FXCollections.observableArrayList(Font.getFamilies());
	fontFamilyComboBox.setItems(fonts);
	// for (String fontFamily : fonts) {
	// if (DEFAULT_OS_FONT.equals(fontFamily)) {
	// fontFamilyComboBox.setValue(fontFamily);
	// }
	//
	// }

	fonts.add("宋体");
	fonts.add("小篆");
	fonts.add("Microsoft YaHei");
	fonts.add("Helvetica");
	fonts.add("TimesRoman");
	fonts.add("Courier");
	fonts.add("Helvetica");
	fonts.add("TimesRoman");

	rootPane.setTop(topBox);
	rootPane.setCenter(box);
}