Changing the background color of a selected JToggleButton

后端 未结 6 2157
暗喜
暗喜 2020-12-07 01:49

I am trying to change the color of a JToggleButton when it has been selected in a reliable, look and feel independent way.

If using the Metal L&F, t

6条回答
  •  自闭症患者
    2020-12-07 01:50

    When it using "Windows look and feel"; in Netbeans you have to do only two things.

    1. Go to properties
    2. Un-select 'contentAreaFilled'
    3. Select 'opaque'
    4. You can set a background color in properties or by hard coding

    In other way,

        jToggleButton.setContentAreaFilled(false);
        jToggleButton.setOpaque(true);
        jToggleButton.setBackground(Color.red); //Your color here
    

    That's all.:-)

提交回复
热议问题