private Button createCharacterBtn(String imgPath, double imgWidth, double imgHeight) { Button characterBtn = new Button(); characterBtn.setMaxWidth(400.0d); characterBtn.setMaxHeight(100.0d); characterBtn.setMinWidth(400.0d); characterBtn.setMinHeight(100.0d); characterBtn.setTextAlignment(TextAlignment.LEFT); ImageView avatarImgBtnLayout = createImageBtnLayout(imgPath, imgWidth, imgHeight); characterBtn.setGraphic(avatarImgBtnLayout); return characterBtn; }
public JavaFXJeopardyBoardViz(Object pane) { mainBoardPane = (StackPane) pane; mainBoardPane.getChildren().clear(); // Create and add children of mainBoardPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); questionText = new Button(""); mainBoardPane.getChildren().addAll(gridPane, questionText); gridPane.toString(); questionText.setMaxWidth(Double.MAX_VALUE); questionText.setMaxHeight(Double.MAX_VALUE); questionText.setWrapText(true); questionText.setTextAlignment(TextAlignment.CENTER); questionText.setStyle( "-fx-text-fill: white; -fx-font-size: 36px; -fx-font-weight: bold; -fx-background-color: #0000FF;"); questionText.setVisible(false); // Set the columns to be equal sizes in the grid for (int col = 1; col <= 6; col++) { ColumnConstraints colConstraint = new ColumnConstraints(); colConstraint.setPercentWidth(100 / 6); gridPane.getColumnConstraints().add(colConstraint); } // Set the rows to be equal sizes in the grid RowConstraints rowConstraint = new RowConstraints(); rowConstraint.setPercentHeight(12); gridPane.getRowConstraints().add(rowConstraint); for (int row = 1; row <= 5; row++) { rowConstraint = new RowConstraints(); rowConstraint.setPercentHeight(88 / 5); gridPane.getRowConstraints().add(rowConstraint); } categoryButtons = new Button[6]; itemButtons = new Button[5][6]; // Add buttons for category titles for (int categoryIndex = 0; categoryIndex <= 5; categoryIndex++) { categoryButtons[categoryIndex] = new Button(categories.get(categoryIndex).getName()); categoryButtons[categoryIndex].setMaxWidth(Double.MAX_VALUE); categoryButtons[categoryIndex].setMaxHeight(Double.MAX_VALUE); categoryButtons[categoryIndex].setWrapText(true); categoryButtons[categoryIndex].setTextAlignment(TextAlignment.CENTER); categoryButtons[categoryIndex].setStyle( "-fx-text-fill: white; -fx-font-size: 14px; -fx-font-weight: bold; -fx-background-color: #0000FF;"); // categoryButtons[categoryIndex].setFont(new Font("Arial Narrow", 14px)); gridPane.add(categoryButtons[categoryIndex], categoryIndex, 0); // Add buttons for BoardItems for (int itemIndex = 0; itemIndex <= 4; itemIndex++) { itemButtons[itemIndex][categoryIndex] = new JeopardyItemButton(categories.get(categoryIndex).getBoardItem(itemIndex)); itemButtons[itemIndex][categoryIndex].setMaxWidth(Double.MAX_VALUE); itemButtons[itemIndex][categoryIndex].setMaxHeight(Double.MAX_VALUE); itemButtons[itemIndex][categoryIndex].setStyle( "-fx-text-fill: gold; -fx-font-size: 24px; -fx-font-weight: bold; -fx-background-color: #0000FF;"); gridPane.add(itemButtons[itemIndex][categoryIndex], categoryIndex, itemIndex + 1); categories .get(categoryIndex) .getBoardItem(itemIndex) .setViz(itemButtons[itemIndex][categoryIndex]); } } }