Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JButton color

 
John Zelek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
//b1.setForeground(Color.RED);
//b1.setBackground(Color.RED);
gamePanel.add(b1);
 
Russell Slighton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic