permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes JButton is not displaying the background color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton is not displaying the background color" Watch "JButton is not displaying the background color" New topic
Author

JButton is not displaying the background color

Dalia Sultana
Ranch Hand

Joined: Jul 16, 2006
Posts: 42
Hi All, I have a JButton that pops up the color chooser on click and changes its background color when a new color is selected. This works fine unless I change the LookAndFeel of the dialog containing the button as follows.

UIManager.setLookAndFeel(new WindowsLookAndFeel());

When the LookAndFeel is set, it appears like the button is on a panel, and the panel is changing its background color. I understand that on WindowsLookAndFeel a gradient is drawn on top of the button to display that 3D look which is why the background color is not being shown. Just wondering if there is a work around for this.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Look on this page down toward the bottom under the heading "Potential Incompatibilities" at (the first) paragraph number 4607364.
Dalia Sultana
Ranch Hand

Joined: Jul 16, 2006
Posts: 42
Great! That helped thanks!
 
 
subject: JButton is not displaying the background color