Sunday, November 25, 2007

Java default icons

I always had the doubt, how to use java's icons? or wich are the default java's icons. for example the Warning icon from JOptionPane, etc.
This could be usefull or I want this because some time I need to use icon fast and easy to test something or just to don't add my own icon.

And now after to search for everywhere and looking inside Java's code i found some of them.

To get defaults icon, you need to ask to javax.swing.UIManager class, wich one have the objects related with look&fell (borders, icons, fonts...)

for example:

Icon icon = UIManager.getIcon("OptionPane.informationIcon");
JButton buton = new JButton(icon);



And the icon list is the next :


Icon
Key
QuestionIcon"OptionPane.questionIcon"
errorIcon"OptionPane.errorIcon"
informationIcon"OptionPane.informationIcon"
warningIcon"OptionPane.warningIcon"
directoryIcon"FileView.directoryIcon"
fileIcon"FileView.fileIcon"
computerIcon"FileView.computerIcon"
hardDriveIcon"FileView.hardDriveIcon"
floppyDriveIcon"FileView.floppyDriveIcon"
newFolderIcon"FileChooser.newFolderIcon"
upFolderIcon"FileChooser.upFolderIcon"
homeFolderIcon"FileChooser.homeFolderIcon"
detailsViewIcon"FileChooser.detailsViewIcon"
listViewIcon"FileChooser.listViewIcon"
expandedIcon"Tree.expandedIcon"
collapsedIcon"Tree.collapsedIcon"
openIcon"Tree.openIcon"
leafIcon"Tree.leafIcon"
closedIcon"Tree.closedIcon"

5 comments:

enos76 said...

The icon set is too narrow to be very useful, but at least now I know it, so I stop wasting time on it. In 100Mb of Java code they could fit a dozen of decent icons though! :-) Thanks, bye

Anonymous said...

This is exactly what I needed thanks. Having the system look and feel is nice but not having your icons on buttons is annoying.

Anonymous said...

Thanks a lot, it's just what I am looking for!

Arfan said...

thank you very much

cravenraven1 said...
This comment has been removed by the author.