Trying to change text of Jlabel multiple times using button
Hi, I'm new to Java. I know a few things, but I don't know enough to even create a valid program that doesn't have an error.
Now, I'm trying to find out how to create a button game, where I use Action listener to count the amount of times that a J button in the center of the screen, and change the text of the J label based on that number. I'm taking a Java class, but I've only had my first day. The teacher demonstrated some scripts, and I requested for him to show a certain script. I took notes, and this is what i currently have/understand a little:
public void action performed(action event arg0) (
clicks += 1;
button=new J button ("")
button.addactionlistener(new actionlistener() (
J label l=new J label();
and something to do with J panel.
I need a script that uses something similar to these, where I can add more changes in the J label's text based on the clicks. Like adding a 2.settext() after 1.settext(), and 3.settext() after 2.settext(), and so on.
So, I would be very grateful if someone were to create a script that has these requirements, and uses "Button Game" as the Project, "gamepack" as the pack, and "game" as the class. :s:
(And just to note, don't critisize me about how I could ask my teacher, beacuse I take the class once I week and I don't know him.)
Re: Trying to change text of Jlabel multiple times using button
Starting to learn programming is a daunting task, but you'll not be able to guess at this and succeed. If you don't have a decent textbook to refer to (or even if you do), I strongly suggest that you check out the Java tutorials here: The Java Tutorials.