MenueController Button highlight

This commit is contained in:
Richard Reiswich 2023-02-01 09:25:40 +01:00
parent b456b6d1d8
commit b7bc440a4f
2 changed files with 330 additions and 133 deletions

View File

@ -1,9 +1,11 @@
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
public class MenueController { public class MenueController {
@ -78,15 +80,8 @@ public class MenueController {
public ObservableList<Node> buttons = FXCollections.observableArrayList(); public ObservableList<Node> buttons = FXCollections.observableArrayList();
public void setButtonActive(Button b){ public void setButtonActive(){
getSiblings(b);
for(Node button : buttons){
button.getStyleClass().remove("active");
if (button.equals(b)){
b.getStyleClass().add("active");;
}
}
} }
public ObservableList<Node> getSiblings(Button b) { public ObservableList<Node> getSiblings(Button b) {
@ -96,4 +91,166 @@ public class MenueController {
} }
public void setButtonActive(Button b) {
getSiblings(b);
for(Node button : buttons){
b.getStyleClass().remove("active");
if (button.equals(b)){
b.getStyleClass().add("active");;
}
}
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtSecondMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btSecondMealMon);
}
@FXML
public void onBtNoMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btNoMealMon);
}
@FXML
public void onBtFirstDessertMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstDessertMon);
}
@FXML
public void onBtSecondDessertMonClick(MouseEvent mouseEvent) {
setButtonActive(btSecondDessertMon);
}
@FXML
public void onBtNoDessertMonClick(MouseEvent mouseEvent) {
setButtonActive(btNoDessertMon);
}
@FXML
public void onBtFirstMealTueClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealTue);
}
@FXML
public void onBtSecondMealTueClick(MouseEvent mouseEvent) {
setButtonActive(btSecondMealTue);
}
@FXML
public void onBtNoMealTueClick(MouseEvent mouseEvent) {
setButtonActive(btNoMealTue);
}
@FXML
public void onBtFirstDessertTueClick(MouseEvent mouseEvent) {
setButtonActive(btFirstDessertTue);
}
@FXML
public void onBtSecondDessertTueClick(MouseEvent mouseEvent) {
setButtonActive(btSecondDessertTue);
}
@FXML
public void onBtNoDessertTueClick(MouseEvent mouseEvent) {
setButtonActive(btNoDessertTue);
}
@FXML
public void onBtFirstMealWedClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealWed);
}
@FXML
public void onBtSecondMealWedClick(MouseEvent mouseEvent) {
setButtonActive(btSecondMealWed);
}
/*
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
@FXML
public void onBtFirstMealMonClick(MouseEvent mouseEvent) {
setButtonActive(btFirstMealMon);
}
*/
} }

View File

@ -17,7 +17,7 @@
<Font size="28.0" /> <Font size="28.0" />
</font> </font>
</Label> </Label>
<Button id="btLogin" alignment="CENTER" layoutX="848.0" layoutY="34.0" mnemonicParsing="false" text="Login" /> <Button id="btLogin" fx:id="btLogin" alignment="CENTER" layoutX="848.0" layoutY="34.0" mnemonicParsing="false" text="Login" />
<HBox layoutX="220.0" layoutY="87.0" prefHeight="414.0" prefWidth="688.0"> <HBox layoutX="220.0" layoutY="87.0" prefHeight="414.0" prefWidth="688.0">
<children> <children>
<VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;"> <VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;">
@ -30,16 +30,24 @@
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" /> <VBox prefHeight="200.0" prefWidth="100.0">
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" /> <children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit"> <Button id="btFoodChoice" fx:id="btFirstMealMon" alignment="CENTER" mnemonicParsing="false" onAction="#onBtFirstMealMonClick" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" />
<Button id="btFoodChoice" fx:id="btSecondMealMon" alignment="CENTER" mnemonicParsing="false" onAction="#onBtSecondMealMonClick" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" />
<Button id="btFoodChoice" fx:id="btNoMealMon" alignment="CENTER" mnemonicParsing="false" onAction="#onBtNoMealMonClick" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" /> <Insets bottom="20.0" />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" /> </children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" /> </VBox>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" /> <VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button id="btFoodChoice" fx:id="btFirstDessertMon" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" />
<Button id="btFoodChoice" fx:id="btSecondDessertMon" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" />
<Button id="btFoodChoice" fx:id="btNoDessertMon" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" />
</children>
</VBox>
</children> </children>
</VBox> </VBox>
<VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;"> <VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;">
@ -52,16 +60,24 @@
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" /> <VBox prefHeight="200.0" prefWidth="100.0">
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" /> <children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit"> <Button id="btFoodChoice" fx:id="btFirstMealTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" />
<Button id="btFoodChoice" fx:id="btSecondMealTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" />
<Button id="btFoodChoice" fx:id="btNoMealTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" /> <Insets bottom="20.0" />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" /> </children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" /> </VBox>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" /> <VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button id="btFoodChoice" fx:id="btFirstDessertTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" />
<Button id="btFoodChoice" fx:id="btSecondDessertTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" />
<Button id="btFoodChoice" fx:id="btNoDessertTue" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" />
</children>
</VBox>
</children> </children>
</VBox> </VBox>
<VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;"> <VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;">
@ -74,16 +90,24 @@
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" /> <VBox prefHeight="200.0" prefWidth="100.0">
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" /> <children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit"> <Button id="btFoodChoice" fx:id="btFirstMealWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" />
<Button id="btFoodChoice" fx:id="btSecondMealWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" />
<Button id="btFoodChoice" fx:id="btNoMealWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" /> <Insets bottom="20.0" />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" /> </children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" /> </VBox>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" /> <VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button id="btFoodChoice" fx:id="btFirstDessertWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" />
<Button id="btFoodChoice" fx:id="btSecondDessertWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" />
<Button id="btFoodChoice" fx:id="btNoDessertWed" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" />
</children>
</VBox>
</children> </children>
</VBox> </VBox>
<VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;"> <VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;">
@ -96,16 +120,24 @@
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" /> <VBox prefHeight="200.0" prefWidth="100.0">
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" /> <children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit"> <Button id="btFoodChoice" fx:id="btFirstMealThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" />
<Button id="btFoodChoice" fx:id="btSecondMealThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" />
<Button id="btFoodChoice" fx:id="btNoMealThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" /> <Insets bottom="20.0" />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" /> </children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" /> </VBox>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" /> <VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button id="btFoodChoice" fx:id="btFirstDessertThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" />
<Button id="btFoodChoice" fx:id="btSecondDessertThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" />
<Button id="btFoodChoice" fx:id="btNoDessertThu" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" />
</children>
</VBox>
</children> </children>
</VBox> </VBox>
<VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;"> <VBox prefHeight="350.0" prefWidth="180.0" style="-fx-background-color: transparent; -fx-padding: 5;">
@ -118,22 +150,30 @@
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" /> <VBox prefHeight="200.0" prefWidth="100.0">
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" /> <children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit"> <Button id="btFoodChoice" fx:id="btFirstMealFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 1" />
<Button id="btFoodChoice" fx:id="btSecondMealFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Mahlzeit 2" />
<Button id="btFoodChoice" fx:id="btNoMealFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="Keine Mahlzeit">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" /> <Insets bottom="20.0" />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" /> </children>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" /> </VBox>
<Button id="btFoodChoice" alignment="CENTER" mnemonicParsing="false" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" /> <VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button id="btFoodChoice" fx:id="btFirstDessertFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 1" />
<Button id="btFoodChoice" fx:id="btSecondDessertFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="78.0" prefWidth="218.0" text="Dessert 2" />
<Button id="btFoodChoice" fx:id="btNoDessertFri" alignment="CENTER" mnemonicParsing="false" onAction="#setButtonActive" prefHeight="20.0" prefWidth="170.0" text="kein Dessert" />
</children>
</VBox>
</children> </children>
</VBox> </VBox>
</children> </children>
</HBox> </HBox>
<Button id="btPlaceOrder" layoutX="379.0" layoutY="527.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="150.0" text="Bestellung abschicken" /> <Button id="btPlaceOrder" fx:id="btSaveOrder" layoutX="379.0" layoutY="527.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="150.0" text="Bestellung abschicken" />
<ComboBox id="cbChooseChild" layoutX="29.0" layoutY="34.0" prefWidth="150.0" promptText="Wähle Kind" stylesheets="@menue.css" /> <ComboBox id="cbChooseChild" fx:id="cbPickChild" layoutX="29.0" layoutY="34.0" prefWidth="150.0" promptText="Wähle Kind" stylesheets="@menue.css" />
<ListView id="lvShowDescription" layoutX="20.0" layoutY="115.0" prefHeight="370.0" prefWidth="200.0" /> <ListView id="lvShowDescription" fx:id="lvFoodInfo" layoutX="20.0" layoutY="115.0" prefHeight="370.0" prefWidth="200.0" />
</children> </children>
</AnchorPane> </AnchorPane>