Which default icons are available?

D

DeMarcus

Hi,

I try to create a simple JButton with an arrow icon that shall look
the same as the arrow buttons in for instance the JScrollPane and
JComboBox.

I've found something like UIManager.getIcon( "Some icon string" )
but which icon strings are available to me? Is this the right way
to copy the look of another component?

Thanks
Daniel
 
T

Thomas Weidenfeller

DeMarcus said:
I've found something like UIManager.getIcon( "Some icon string" )
but which icon strings are available to me?

This is not documented anywhere. In general, there is no reliable API to
get internal icons, especially not in a PLAF-independent way. You can
get the UIDefaults via the UIManager and print all the defaults (it is a
Map). There is e.g. a small tool called ShowUIDefaults.java out there
doing this with a GUI.

This list will contain among other things the icon key/value pairs, so
you will see which ones are available for the current PLAF. But another
PLAF or another VM implementation might provide a completely different
set of icons, or no icons at all.

If you want to deal with Metal only, you can use
javax.swing.plaf.metal.MetalIconFactory to get Metal-Related icons. This
is at least a public API, although not a really good one. You could also
snoop round in the javax.swing.plaf.basic.BasicIconFactory for some more
icons.

/Thomas
 
D

DeMarcus

Thomas said:
This is not documented anywhere. In general, there is no reliable API to
get internal icons, especially not in a PLAF-independent way. You can
get the UIDefaults via the UIManager and print all the defaults (it is a
Map). There is e.g. a small tool called ShowUIDefaults.java out there
doing this with a GUI.

This list will contain among other things the icon key/value pairs, so
you will see which ones are available for the current PLAF. But another
PLAF or another VM implementation might provide a completely different
set of icons, or no icons at all.

If you want to deal with Metal only, you can use
javax.swing.plaf.metal.MetalIconFactory to get Metal-Related icons. This
is at least a public API, although not a really good one. You could also
snoop round in the javax.swing.plaf.basic.BasicIconFactory for some more
icons.

/Thomas

Ok, thanks. I'll check that out.

/Daniel
 
Joined
Oct 17, 2008
Messages
2
Reaction score
1
More info

This page (http://forums.sun.com/thread.jspa?threadID=5338038) has some code sample that shows the default values for a given theme, thus teling which icon strings it supports.

For the Nimbus look and feel, I got this info:
Tree.collapsedIcon
FileChooser.directoryIcon
FileChooser.detailsViewIcon
OptionPane.questionIcon
FileChooser.newFolderIcon
FileView.floppyDriveIcon
Tree.openIcon
Tree.expandedIcon
OptionPane.informationIcon
Tree.closedIcon
Tree.leafIcon
FileChooser.upFolderIcon
OptionPane.errorIcon
ToolBar.handleIcon
FileChooser.floppyDriveIcon
FileChooser.fileIcon
RadioButton.icon
FileView.fileIcon

Haven't tested all values though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top