wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JButton color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton color" Watch "JButton color" New topic

JButton color

John Zelek

Joined: Nov 10, 2012
Posts: 2
I am trying to set up an interface with nine buttons, each with a different color. How do I set/change the color of each of the buttons. I am not trying to change the text color on the button. I am trying to change the color of the button itself. Seems like a simple task but not finding anything. I am trying to mimic the game Simon Says and I would like each button to be a different color, not just the border

JButton b1 = new JButton("1");
Russell Slighton

Joined: Nov 18, 2012
Posts: 5
You could try to add a border then setBackgroundColor(), however, after adding a border, the button will not darken when clicked and will also looses several graphical functions. (But not functional functions)
subject: JButton color
Similar Threads
Trying to make a button but don't know where to start
jButton revalidate, updateUI, repaint does not working
How to change color of a content pane after using borderlayout
Background color not inherited from the immediate container
Pulling out hair