Skip to main content

how to apply gradient colors to titlebar,jbuttons,jcombobox,jtabbedPane

1 reply [Last post]
indianap1
Offline
Joined: 2006-09-16
Points: 0

Iam developing a swing application in which I want to use gradient colors to jframe's titlebar, jbutons,jcomboboxes,jtabbedpane,jpanel,etc.,
I have tried Substance Look And Feel.But I want to use colors which are not given in substance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
araghuna
Offline
Joined: 2007-02-09
Points: 0

I think I might be able to help you (I hope):
You can create a SimpleGradientPanel...something like
JPanel gradPanel = new SimpleGradientPanel(); (I forgot the syntax exactly)
then, set the startColor and endColor properties of gradPanel, something like:
gradPanel.startColor = the start color you want for your gradient
gradPanel.endColor = the end color you want for your gradient

Then add the titlebar, jbutton, or whatever you want to this panel, using the add function of JPanel.

To get a better idea of how the SimpleGradientPanel works, you can check out:
http://blog.elevenworks.com/files/infopanel/SimpleGradientPanel.java