Zayne Zayne - 1 year ago 81
Java Question

How to store the filename of an Icon as a String?

So let's say I have some Icon:

Icon something = new ImageIcon("somefile.png");

And I want to store that
in some Strings. How do I do that?

Obviously I can not do
or cast so I am kind of stumped by what I am sure it has a simple solution.


Answer Source

As you see here :

The filename goes directly to the description-Field what is used in the toString(). Try

String filename = something + "";

What indirectly calls the .toString().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download