How to set a background color of a JButton in Java?

后端 未结 6 1498
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 19:33

I am developing a Java Desktop Application. In it I have 4 JButtons on a JPanel. Now I want that whenever a button is clicked its background color

6条回答
  •  粉色の甜心
    2021-01-18 20:22

    Here's a cross-section of "Button.background" based on this example:

    *** Metal javax.swing.plaf.metal.MetalLookAndFeel 636 entries
    Button.background: javax.swing.plaf.ColorUIResource[r=238,g=238,b=238]
    
    *** Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 1052 entries
    Button.background: com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel$NimbusProperty@60961dff
    
    *** CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel 550 entries
    Button.background: javax.swing.plaf.ColorUIResource[r=174,g=178,b=195]
    
    *** Mac OS X com.apple.laf.AquaLookAndFeel 705 entries
    Button.background: com.apple.laf.AquaNativeResources$CColorPaintUIResource[r=238,g=238,b=238]
    

提交回复
热议问题