aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to set the color of a button and toolbar ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set the color of a button and toolbar ?" Watch "How to set the color of a button and toolbar ?" New topic
Author

How to set the color of a button and toolbar ?

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
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


yours respectfully<br />Avin Sinanan
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
The same goes for JToolBar.
 
Consider Paul's rocket mass heater.
 
subject: How to set the color of a button and toolbar ?