开发者

swing: creating "record" and "stop" buttons

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜