ARTICLE AD BOX
I have 2 main nodes. One is the side menu which works perfectly and the function menu which is supposed to continue the bottom of the side menu to the end of the width of the screen. Somehow HBox isn't showing when set using bp.setBottom(hb). This is the code. (Sorry if its unorganized or unprofessional, I am new but I am willing to take tips if you have.) Thanks.
package org.example.travelplanner.view; import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.scene.text.Font; import org.example.travelplanner.controller.Controller; public class HomePane extends MainPanes { private BorderPane bp; private int numofverticalbuttons; private Color bgcolor; private int numofhorizonbuttons; private HBox functionmenu; private double sidemenuwidth; public VBox sidemenu; public HomePane(Controller cr) { super(cr); bp = new BorderPane(); super.getPane().getChildren().add(bp); initHomePane(); } public void initHomePane() { initSideMenu(); initDownMenu(); } public void initSideMenu() { sidemenu = new VBox(4); sidemenu.prefHeightProperty().bind(getPane().heightProperty()); sidemenu.prefWidthProperty().bind(getPane().widthProperty().multiply(0.16)); bgcolor = new Color(0.1, 0.1, 0.05, 0.1); sidemenu.setBackground(new Background(new BackgroundFill(bgcolor, CornerRadii.EMPTY, new Insets(0)))); Label companytag = new Label("TP"); companytag.setFont(new Font(100)); companytag.getStyleClass().add("tag_label"); sidemenu.getChildren().add(companytag); sideMenuButtons(); Label lasthistory = new Label("Last trips:"); lasthistory.getStyleClass().add("unusedlabel"); sidemenu.getChildren().add(lasthistory); bp.setLeft(sidemenu); } public void sideMenuButtons() { sidemenuwidth = getWidth() / 6; numofverticalbuttons = 3; for (int i = 0; i < numofverticalbuttons; i++) { Button button = new Button(); sidemenu.getChildren().add(button); button.setPrefSize(sidemenuwidth, 10); if (i == 0) { button.setText("Settings"); } if (i == 1) { button.setText("Plans"); } if (i == 2) { button.setText("Coming\n Trips"); button.setPrefSize(sidemenuwidth, 60); } button.getStyleClass().add("home_button"); } } public void initDownMenu() { functionmenu = new HBox(10); numofhorizonbuttons = 3; double prefheight = 100; functionmenu.setPrefHeight(prefheight); functionmenu.prefWidthProperty().bind(getPane().widthProperty()); functionmenu.setBackground( new Background(new BackgroundFill(bgcolor, CornerRadii.EMPTY, Insets.EMPTY))); functionButtons(); bp.setBottom(functionmenu); } public void functionButtons() { for (int i = 0; i < numofhorizonbuttons; i++) { Button button = new Button(); functionmenu.getChildren().add(button); button.setPrefSize(30, 30); if (i == 0) { button.setText("button1"); } if (i == 1) { button.setText("button2"); } if (i == 2) { button.setText("button3"); } button.getStyleClass().add("home_button"); } } }New contributor
anonymou is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Explore related questions
See similar questions with these tags.
