Hbox wird nicht angezeigt, wenn unten eingestelltJava

Java-Forum
Anonymous
 Hbox wird nicht angezeigt, wenn unten eingestellt

Post by Anonymous »

Ich habe zwei Hauptknoten. Eines davon ist das Seitenmenü, das einwandfrei funktioniert, und das Funktionsmenü, das sich vom unteren Rand des Seitenmenüs bis zum Ende der Bildschirmbreite fortsetzen soll. Irgendwie wird HBox nicht angezeigt, wenn es mit bp.setBottom(hb) eingestellt wird. Das ist der Code. (Es tut mir leid, wenn es unorganisiert oder unprofessionell ist, ich bin neu, aber ich bin bereit, Tipps anzunehmen, wenn Sie welche haben.) Danke.

Code: Select all

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");
}
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post