【问题标题】:Swing setBackground Non-Color Class ValuesSwing setBackground 非颜色类值
【发布时间】:2013-09-27 17:54:46
【问题描述】:

我正在尝试为我的摇摆 UI 的某些区域着色,但感觉受到使用的限制

.setBackground(Color.//color here

有什么方法可以在其中使用更具体和独特颜色的十六进制值(甚至没有棕色)?每当我尝试时,都会显示一个错误。

【问题讨论】:

  • 您可以使用 RGBA 值来创建自己的颜色和/或查看 these 将十六进制转换为 RGB 的示例

标签: java swing colors awt rgb


【解决方案1】:

试试

new Color(int r, int g, int b) 

RGB

new Color(int r, int g, int b, int a) 

对于 ARGB(a=alpha 透明度)

【讨论】:

  • 我怎么能用这样的设置来实现它,我得到一个错误,指出颜色是 undefined for int,int,int: buton1.setBackground(Color(175, 178, 35)) ;
  • button1.setBackground(new Color(175, 178, 35));
  • 啊,请原谅我失言,谢谢,非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-11
  • 2012-04-07
  • 2016-09-22
相关资源
最近更新 更多