public void setDisplay(int index) {
flowPane.setTitle(menuItems[index]);
flowPane.setGridPane(menuActions[index]);
}
this is the full code it's incomplete but it should compile
package pkgfinal;
import javafx.application.Application; //
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene; //
import javafx.stage.Stage;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
public class Final extends Application {
//adding actions to the drop down menu
private String[] menuItems = {"Inmate Booking", "Release Inmate", "View Inmate Status ",
"Update Inmate Status", "View Vistor Log","List Inmates","View All Inmates" }; //you can view the vistor log by name or date or prisoner
//you can view inmate by name and cellblock for list inmates
//create combobox for dropdown menu
private ComboBox<String> combo = new ComboBox<>();
//create gridpane to hold actions(?)
private GridPane[] menuActions = new GridPane [7];
//creating new flowpane
private FlowPane flowPane = new FlowPane();
@Override
public void start(Stage primaryStage) {
//set menu actionse
menuActions[0] = bookInmate(); //to book an inmate in the system
menuActions[1] = releaseInmate(); //to release inmate from the prison
menuActions[2] = viewStatus(); //to view an imates status
menuActions[3] = updateImate(); //to updates inmates status
menuActions[4] = visitorLog(); //to view visitor log by name and
menuActions[5] = listInmates(); //to list inmates in prison by name or cellblock
menuActions[6] = viewAllInmates(); //to view all inmates
setDisplay(0); //set book an inmate as the deafult
BorderPane border = new BorderPane();
BorderPane pane = new BorderPane();
pane.setLeft(new Label("Select action from menu: "));
pane.setCenter(combo);
border.setTop(pane);
combo.setPrefWidth(500);
combo.setValue("Inmate Booking");
ObservableList<String> items =
FXCollections.observableArrayList(menuItems);
combo.getItems().addAll(items);
pane.setCenter(flowPane); //adding to combo box
combo.setOnAction(e -> setDisplay(items.indexOf(combo.getValue()))); //display pane user selected
//setting scene for menu actions
Scene scene = new Scene(border, 500, 500);
primaryStage.setTitle("Booking System");
primaryStage.setScene(scene);
primaryStage.show();
}
public void setDisplay(int index) {
flowPane.setTitle(menuItems[index]);
flowPane.setGridPane(menuActions[index]);
}
private GridPane bookInmate() {
return null;
}
private GridPane releaseInmate() {
return null;
}
private GridPane viewStatus() {
return null;
}
private GridPane updateImate() {
return null;
}
private GridPane visitorLog() {
return null;
}
private GridPane listInmates() {
return null;
}
private GridPane viewAllInmates() {
return null;
}
}

New Topic/Question
Reply


MultiQuote





|