![Color for a button java swing on mac](https://kumkoniak.com/6.jpg)
![color for a button java swing on mac color for a button java swing on mac](https://1.bp.blogspot.com/-KBzZuDLnKkM/XUEPtDlWJ4I/AAAAAAAAAWw/dkUnYVm4PqQVnP0ApqBMv2M4svSDe7inQCEwYBhgL/s1600/jbmac2.png)
If you set the background color for a JLabel, for example, you must also invoke setOpaque(true) on the label to make the label's background be painted.
![color for a button java swing on mac color for a button java swing on mac](https://i.stack.imgur.com/wi1im.jpg)
Most likely, your component isn't painting its background, either because it's not opaque or your custom painting code doesn't paint the background.Problem: I used setBackground to set my component's background color, but it seemed to have no effect. G.fillRect(0, 0, getWidth(), getHeight()) You can paint the background yourself using this code at the top of a custom component's paintComponent method:.If your custom component extends JPanel or a more specialized JComponent descendant, then you can paint the background by invoking super.paintComponent before painting the contents of your component.To make components such as JLabels and GTK+ JPanels opaque, you must invoke setOpaque(true) on them. JPanels, for example, are opaque by default in many but not all look and feels. The result is that one or more components directly behind my component are unexpectedly visible. Problem: My component's foreground shows up, but its background is invisible. Check whether repaint is invoked on your component whenever its appearance needs to be updated.Solving Common Component Problems should help you with this. Check whether your component is showing up at all.Problem: The stuff I paint doesn't show up. Painting code belongs in the paintComponent method of any component descended from JComponent.Problem: I don't know where to put my painting code.
![Color for a button java swing on mac](https://kumkoniak.com/6.jpg)