I’m having troubles setting the background color for JButtons.
For example I get this when I do button.setBackground(Color.ORANGE)

But when I disable the GTK Look and Feel it’s ok.
Another way to set the background?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GTK Look and Feel defines its own way to visually present the button, so when you use “button.setBackground(Color.ORANGE)” it only changes button underlying background and then the GTK Look and Feel draws its own (gray) representation of the button atop of the background.
In case you want a simple orange-colored button you can change button’s UI for your own one, for example:
This code sample will create a button that is gray on press and orange when its not pessed.
Ofcourse you can style the painting as you like and change the button view.