开发者

Overriding the paint() method in JButton

I have a class that extends JButton because the custo开发者_StackOverflow社区m look and feel I'm using ignores the isOpaque() call. What I mean is, the background of the button is rendered even though I have called setOpaque (false) on it and all parent panels. I have confirmed that this is an issue with the LAF from the companies design people so there is nothing I can do but extend the class. So my question is, how can I implement the paint() method to not render the background and just the button icon? Cheers

SOLVED: The answer I was after in case anyone is interested was to use button.setContentAreaFilled(false);


Painting is done by three methods: paintComponent, paintBorder, and paintChildren. They're called in that order and it's the first that paints the component's background. If you overload that one and leave the other two, you should be fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜