JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.34k stars 266 forks source link

JButton background color #516

Closed lrhuff8 closed 2 years ago

lrhuff8 commented 2 years ago

I am converting an application that was using Nimbus for dark mode, and the move to FlatLaf is a dramatic improvement. My plan is to move to using FlatLaf in both lite and dark mode, as a complete replacement for our cross-platform L&F (Nimbus) and as a potential replacement for our use of the Windows L&F as well. I truly want to recognize all of the work -- it is just tremendous. I am currently looking at an issue where the background color on JButtons does not seem to be working after assigned. I have attached an example, where I set the background color to green, but that assignment only shows around the component edges. Should this work? The color is set from a class that extends JButton, using code as follows: this.setBackground(Color.green).

image

DevCharly commented 2 years ago

Looks like you're using a custom button implementation, right?

A FlatLaf button looks different, and setting background works as expected:

image

lrhuff8 commented 2 years ago

I appreciate the very quick response. After some testing, I determined that my issue was setting "ContentAreaFilled" to false. It works with that setting removed, where I then only set Opaque to false.