tags:

views:

54

answers:

2

I see that there is a JButton constructor which takes an Icon as a parameter... but how do I get an Icon from a bitmap file?

Also, are there "record" and "stop" Icons available from the default look and feel? or do I have to provide them myself?

+3  A: 

You can create an ImageIcon from a URL, among other things (including a filename or a byte array).

You can also pass any Image into the constructor, meaning you can take full advantage of the ImageIO utility class.

Mark Peters
+1  A: 

You can get icons by name from the L&F, as shown below and in this example.

Icon icon = UIManager.getIcon("OptionPane.errorIcon");

You can see what's available using Rob Camick's handy UIManager Defaults.

Addendum: Another approach is to implement the Icon interface and draw the icon using Graphics2D primitives, as shown here.

trashgod