Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set the color of a button and toolbar ?

 
Avin Sinanan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I was wondering if anyone out there knows how to set the colour of a JButton and a JToolBar to say.. red .
Usually the button and toolbars are grey. I want to change this to give the program a more professional look.
any ideas?
thanks
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JButton inherits setBackground(Color) from JComponent. So, this:

JButton jbutton = new JButton("JButton");

jbutton.setBackground(Color.red);

creates a new JButton and sets its color to red.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same goes for JToolBar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic