vendredi 27 avril 2018

Integer not working with an if statement

I am making a text based game, and I am experimenting with different ways of making the storyline of the game progress. (Im sorry if this is semi-hard to follow, I am new to this website, and still fairly new to Java, I'm making this for a class project)

One of the ways I am trying is by increasing a value (In this case LevelNum) by one, and whenever a number not equal to zero is displayed it will set the text of jLabel1 to whatever the text is.

I am trying to do this by using an if statement as shown here:

if(LevelNum == 0) {
                jLabel1.setText(StoryData.LevelOne);
            }

The increase of LevelNum is done like this:

public void actionPerformed(ActionEvent e) {
                    LevelNum += 1;
                    System.out.println(LevelNum);

            }

(The System.out was just to check to see if it was increasing the number)

The problem I am running into is that no matter what the value of jLabel1 is, the text never changes, and I dont know why.

The whole code can be found here: https://pastebin.com/JSX6urFT

The StoryData is a seperate class within in my text document, and the individual strings look like this: static String LevelOne = "Level one test";

Aucun commentaire:

Enregistrer un commentaire