Advertisement Jump to content
Sign in to follow this  
luckylavs

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

This topic is 2839 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!