如何设置JButton的按钮颜色(不是背景颜色) [英] How to set the button color of a JButton (not background color)
问题描述
我有 JButton
,我想将背景颜色更改为白色。使用金属外观时,我使用 setBackground
实现了预期的效果:
I have a JButton
that I would like to change the background color of to white. When using the Metal Look And Feel, I achieve the desired effect with setBackground
:
不幸的是,使用Windows LAF时,背景颜色的概念不同;背景颜色是按钮周围绘制的颜色:
Unfortunately, the concept of "background color" is different when using the Windows LAF; the background color is the color drawn around the button:
我想使用Windows LAF,但允许此<$ c $的按钮颜色c> JButton 将更改为白色。我该怎么做?
I would like to use the Windows LAF, but allow the button color of this JButton
to be changed to white. How do I do this?
推荐答案
你必须决定是否值得付出努力,但你总是可以自己创造 ButtonUI
,如下所示示例由于@mKorbel。
You'll have to decide if it's worth the effort, but you can always create youe own ButtonUI
, as shown in this example due to @mKorbel.
这篇关于如何设置JButton的按钮颜色(不是背景颜色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!