How do i get make the correctLabel to have all the text disappear so there is NO "correct" and the "buttonclicked values". I have been tryin but i can only manage to get the "correct" to dissapear the button clicked values are not removed

correctLabel.setText("Correct: " ); // this sets the label like so "correct:"
footer.add(new JLabel(buttonClicked.getText())); // when a button is clicked it takes the value and adds it to  
the correctLabel like so "correct: 1, 2, 3"

when a user gets a answer wrong it takes away the "correct" so i am just left with 1,2,3the code i use to do this is

correctLabel.setText(" ");

i have tried correctLabel.setText("Correct: " - buttonClicked ); but this doesnt work. can someone help me understand the correct way of doing this.

i.e. correctLabel's text " "

full code
[code]

        if (clickedNumber == (gui.buttonCounter + 1)) {


        if (gui.buttonCounter == (gui.ROWS * gui.COLUMNS) - 1) {

            gui.reset();
            gui.correctLabel.setText("");


        } else {
            gui.buttonCounter++;

            footer.add(new JLabel(buttonClicked.getText()));
            buttonClicked.setText("");// optional - clears correct selection
        correctLabel.setText("Correct: " - buttonClicked );                
        footer.revalidate();
            if (gui.buttonCounter > gui.ROWS * gui.COLUMNS) {
                gui.reset();

            }
            gui.statusLabel.setText("click" + gui.buttonCounter + "+1");
        }
    } else {
        gui.reset();

        gui.statusLabel.setText("start again ");

    }
  }
  }[/code]

.setText("");
IS what you have to do to clear the text. you could also put:
.setVisible(false);
or something similar.
has it ever occurred to you that the reason it's not being executed is because your if-statement never returns true?

i think what the problem is that i have a seperate correct label, the label where the buttonclicked are shown is on a newJLabel.

   footer.add(new JLabel(buttonClicked.getText()));

this code does execute but for the correctLabel and not the new

JLabel(buttonClicked.getText
correctLabel.setText(" ");

soolved it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.