Hi guys,
I am a little stuck, the aim it reset the gui and the correct label.
I only have the gui to reset, how do rest the correct label?(footer)
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi guys,
I am a little stuck, the aim it reset the gui and the correct label.
I only have the gui to reset, how do rest the correct label?(footer)
Last edited by newtolearningjava; April 26th, 2014 at 05:57 PM.
What do you mean by "reset"? What have you tried? Where are you stuck?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
reset as in bring the gui back to its original state so the game can be played again. which i can using this code [code] public void reset() {
i have added a correct label in the code but i am not able to reset the text for that
Last edited by newtolearningjava; April 26th, 2014 at 05:57 PM.
Why aren't you able to reset the text for that JLabel?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
i am not sure on how do to this, that is why i asked and created the thread
Last edited by newtolearningjava; April 14th, 2014 at 08:27 AM.
You've posted code that sets the text of a JLabel. What is preventing you from using that code on the JLabel you want to reset?
--- Update ---
This thread has been cross posted here:http://stackoverflow.com/questions/23060521/reset-the-text-for-that-jlabel
Although cross posting is allowed, for everyone's benefit, please read:
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
nlmk
Last edited by newtolearningjava; April 26th, 2014 at 05:58 PM.
You're adding these JLabels to the footer, but you have no reference variable for them, so there's no direct way to set their text to "". But I don't think that's what you really want, I think you want to get rid of them altogether (because new ones will be created during the next game). In that case you're looking for footer.removeAll() and footer.revalidate().footer.add(new JLabel("Correct: ")); ... footer.add(new JLabel(buttonClicked.getText()));
here is my code i dont think i should get rid of them
QUESTION IS
Last edited by newtolearningjava; April 26th, 2014 at 05:58 PM.
help
the current code prints out "correct: 1,2,3,4") "1234 are the button click values" once these the game is over i want the label to go blank
the current
Last edited by newtolearningjava; April 26th, 2014 at 05:59 PM.
You have this:
gui.correctLabel.setText("");
If you don't understand my answer, don't ignore it, ask a question.
Baffled. I don't understand why the line below won't work.
label.setText( "" );
If you can provide more info as to why it is more difficult than that, please do.
Duplicate threads merged.
i am not sure why myself, is spent a whole day trying to work it out but i have got no where. please can someone help me my head is going to explode
Last edited by newtolearningjava; April 26th, 2014 at 05:59 PM.
If the statement is not executed, the label is not cleared. Is the if statement true?
Add a println() statement to show the values used in that if statement to see what it sees when it is executed.if (gui.buttonCounter > gui.ROWS * gui.COLUMNS) {
If you don't understand my answer, don't ignore it, ask a question.
Did you have a question or comment?
If you don't understand my answer, don't ignore it, ask a question.
whats wrong with my code? why doesnt the
Last edited by newtolearningjava; April 26th, 2014 at 06:00 PM.
Sorry, that last post does not make sense. Labels don't interact. It's the code that makes changes to labels.why doesnt the correctLabel take the buttonclicked values away from it?
What do you expect to be in each label AFTER that code executes?
Give the name of the label and its expected contents.
If you don't understand my answer, don't ignore it, ask a question.
How do
Last edited by newtolearningjava; April 26th, 2014 at 06:00 PM.
Execute this code:make the correctLabel to have all the text disappearcorrectLabel.setText(" ");
Is the program executing that code? If not, why isn't it?
What are the values of the variables used in the if statement that controls if that statement is executed?
If you don't understand my answer, don't ignore it, ask a question.
i think what the
Last edited by newtolearningjava; April 26th, 2014 at 06:00 PM.
New labels without reference variables are hard to access if you want to change their values.
If you don't understand my answer, don't ignore it, ask a question.