problem with JLabels
this is my first time writing, and i need some help.
i want to be able to make a JLabel in which i can store a value (such as int) which i can add one or subtract one from. it doesn't seem to like:
JLabel score = new JLabel(num);
int num = 5;
i probabely have done soemthing really stupid or missed soemthing out but hey! i'm new to java.
if you can help me: thank you so much, because i am really confused. :confused:
Welcome, geork, to Java Forums!
First, you must declare the integer, num, and then you can use it like this:
I do this, because this construction is expecting an argument of type String. To convert the number into a String, you can create a new Integer object and then use its toString() method.
int num = 10;
JLabel label = new JLabel(([COLOR="RoyalBlue"]new Integer(num)[/COLOR]).[COLOR="Teal"]toString()[/COLOR]);
Hope this helped. :D
thank you guys sooooo much :)