Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

variable.setIcon() ?  RSS feed

 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I need help inserting variables with setIcon()...

Example:



I am new to Java... sorry if this is total newb stuff : s

Thank you for your time!
 
Piet Souris
Rancher
Posts: 1782
54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Alex,

although you are not very explicit about what problem you have, by looking
at your code I can see the following.

Look at lines 03 and 08. The variable 'v' is a String (line 03), and in line 08
you try to apply the method 'v.setIcon(..)'.

Now, a String does not have this method. What you need to do is to determine
to what Label/Button/whatever component you want to put your icon on.

So, in line 03, determine the component in question, call it v, and you're done.
Maybe you can give this component as a parameter in your method?

Greetz,
Piet
 
Alex Desjardins
Greenhorn
Posts: 10
Eclipse IDE MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you you're reply helped a lot. This test worked:



Edit:

Hum, but I don't know how to iterate the cardImg_1_1 in:



cardImg_1_+i

Edit 2:

I can get it to work with this:

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!