JLabel设置颜色

用到JLabel设置颜色。setBackground(Color color)。结果没显示。网上看了看都说加上html就行了。觉得不好。再搜。原来还有个setOpaque(boolean bool);这个方法设置true就可以了。原来这是设置透明度,java默认是设置的false。即透明。(opaque,经过翻译是不透明的意思。呵呵)。只要设置成不透明,颜色自然看到了。
把该方法贴一下


public void setOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.
The default value of this property is false for JComponent. However, the default value for this property on most standard JComponent subclasses (such as JButton and JTree) is look-and-feel dependent.


Parameters:
isOpaque - true if this component should be opaque
See Also:
isOpaque()


  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值