Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get a button icon's path !?

Status
Not open for further replies.

khashyar7

Technical User
Aug 11, 2004
69
CA
Hi,

I need to get the path of a Jbutton's icon. Mathod getIcon() gives me an Icon, but inside the Icon interface, I could not find any method that returns the address where the icon is stored.

Please help if u can.
 
I don't think that information is carried through into the Icon. Once the Icon is loaded it's original file resource is immaterial.

Maybe if you say why you need it, someone may suggest an alternate approach to your problem.

Tim
 
I am making a simple GUI builder. One of the features is save the design... It basically saves the properties of the components set by the user in a space delimited file. Then I need to retrieve the design from this file once the user opens the design file.

Say for a JButton, I need to know what is the path of the icon that the user selected, so I can recreate a JButton with those preset properties.

I hope that clerified a little.

Cheers,

Kash
 
Well, I suppose you're gonna have people browsing for images to put on components. You'll have to store the location of those images yourself and persist this info in your file.

On a different point, you say you're holding the component properties in a space delimited file. Are you aware that from JDK1.4 you can persist objects which conform to the JavaBean spec as XML files. The saving and loading work is done for you. Have a look at the java.beans.XMLEncoder and java.beans.XMLDecoder classes.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top