I am creating a game. For that game, there should be a "Play" Button (already added) and a rules button (the one I am trying to add). For some reason, when I try to add the rules button, it never shows up in the screen. Inside the rules tab I just want to add the rule content of the game. Any suggestions? Here is my code:
package com.example.jaxafx_practice;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import java.io.IOException;
//import com.example.jaxafx_practice.Playscene.playscence;
public class Main extends Application {
Scene StartScene;
@Override
public void start(Stage primary) throws IOException {
// ********Start scene************
Button PlayButton = new Button("Play");
PlayButton.setMinWidth(55);
PlayButton.setMinHeight(30);
VBox layout1 = new VBox(250.0);
layout1.setAlignment(Pos.CENTER);
Label StartSceneLabel = new Label("Wordle");
StartSceneLabel.setMinWidth(55);
StartSceneLabel.setMinHeight(30);
StartSceneLabel.setAlignment(Pos.CENTER);
StartSceneLabel.setStyle("-fx-background-color: #FFFFFF;");
layout1.getChildren().addAll(StartSceneLabel, PlayButton);
primary.setTitle("Start screen");
layout1.setStyle("-fx-background-color:#800000");
HBox user_interface=new HBox();
// Creates Start scene
StartScene = new Scene(layout1, 500, 750.0);
// ********Start scene************
//????????Play scene?????????????
Playscene playscene = new Playscene();
//????????Play scene?????????????
//Create the word to be guessed
Choose_word Choose_word = new Choose_word();
String wordToGuess = Choose_word.getWord();
//Button actions
PlayButton.setOnAction((e) -> {
primary.setScene(playscene.playscence());
primary.setTitle("Game Screen");});
primary.setScene(StartScene);
primary.show();
playscene.enterButton.setOnAction((e) -> {
String userWord=playscene.guessField.getText();
if(userWord.length()==4)
{playscene.displayWord(userWord.toLowerCase(),wordToGuess);
playscene.count+=1;}
});
primary.setScene(StartScene);
primary.show();
}
public static void main() {
launch();
}
}