Hello. I am new to jave so please forgive my newbishness. I've used Netbeans IDE 6.0 to construct a GUI for my project. However I have ran into a few problems;

1. I cant seem to get a jButton to change the text of a jLabel. (im trying to get the label to be as 00, and a button to add 1 to the label. i just dont no how to import it into Netbeans)
2. I have built a timer applet that im trying to incorperate into my Netbeans project.

How would i go about doing this? I've gone on the sun tutorials as well as other netbeans tutorials on the internet and im still not having any luck. Thanks :)

1. Right click on the button and add a new action listener. In the action listener get the current text of the label, make it an integer, and add one to it. Then reset the labels value.

2. I'm assuming that all you would need to do is include your jar file within the project as a library.

If you post your code I can provide more assistance.

if you're just starting with Java, it might be a good idea to leave IDE's such as NetBeans out of it for a while. true, they come in handy, and you get the job done, you just don't really know how it works, and in the end, that's the important thing.

resetting or changing a text in a JLabel when pressing a JButton is basic stuff, which doesn't need much more knowledge than the use of a method to call on getters and setters. and that is, as I already mentioned, very basic.

post the relevant code here, and add you own commentary, about what you think it does, then it'll be easier for us to tell you you're on the right track or not.

//First Define the Integers
//addOne is the function to add 1 to the currentValue of the Label
//currentValue is the value of the label
//result is the final answer        
int addOne, currentValue, result;
//add 1 to the currentValue
result = addOne + currentValue;
//set the text for the label
jLabel3.setText(String.valueOf(result));

The problem i am having atm, is setting the jLabel3 to an integer value. How would I go about this?

jLabel3.setText(String.valueOf(result));

The problem i am having atm, is setting the jLabel3 to an integer value. How would I go about this?

doesn't that line do that? or do I misunderstand your question?

doesn't that line do that? or do I misunderstand your question?

It was my fault, i was unclear. However by fluke i got it to work. Thanks!

Edited 6 Years Ago by Shmoil: n/a

This question has already been answered. Start a new discussion instead.