Results 1 to 2 of 2
- 10-11-2012, 01:07 AM #1Member
- Join Date
- Oct 2012
- Rep Power
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.
(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.
- By fatabass in forum AWT / SwingReplies: 1Last Post: 02-11-2012, 04:07 AM
- By relith in forum New To JavaReplies: 3Last Post: 10-27-2010, 09:38 AM
- By sidd0123 in forum New To JavaReplies: 3Last Post: 06-06-2010, 03:02 AM
- By pmgallardo in forum Advanced JavaReplies: 6Last Post: 03-09-2009, 05:29 PM
- By robot in forum NetBeansReplies: 0Last Post: 11-20-2008, 07:04 AM