Jump to content
  • Advertisement
Sign in to follow this  
luckylavs

Java Question: How to refer to an Icon using concatenated Strings?

This topic is 2596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my problem. I have created many different icon objects, each named with this general format:

<name><direction><number>icon

For example, billdown5icon, steveright2icon, etc.

I want to repeatedly change a JLabel's icon to accomplish a simple animation

So I am trying:

myLabel.setIcon
(name+direction+number+"icon");

But Java is expecting an Icon as the argument, and here I'm giving it a string. I don't want to give it a String, I want to say "use the icon which has this particular name"

Is there an easy way to do this?

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!