wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Changing colors on my swing app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing colors on my swing app" Watch "Changing colors on my swing app" New topic
Author

Changing colors on my swing app

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
I would like to change colors on my Swing app; I do not need to change anything else about the look and feel. I want to do this while the application is running.

I have found a method that, when put in a class that extends one of the basic look and feel classes, does some of what I want. It has the following method in it:



When I change to this look and feel while the app is running, a number of colors on the UI change. So far so good.

Some of the colors on the UI, however, do not change. Is there a way to add to the above method so that I have control over all (or at least more of) the colors?

For instance, the background color for the menu and toolbar do not change, and I would like them to. I also think I could make things better looking if I had control over the slider bars and their backgrounds, etc.

One frustrating thing is that the comments in the above code (which were included with the code, they aren't mine) don't seem to match what happens. For instance, one of them claims to be the color for title bar captions when they are active, another claims to be the color for the color of the window border, but I can't get any change to the UI by setting either of those colors.

Anyway, if someone knows where I could find a complete list of colors, or anything else of note about this method, I'd appreciate it.

rc
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

a number of colors on the UI change. So far so good.

Some of the colors on the UI, however, do not change.

Have you gone through Changing the Look and Feel After Startup?

one of them claims to be the color for title bar captions when they are active, another claims to be the color for the color of the window border, but I can't get any change to the UI by setting either of those colors.

Sounds like you're not using the LaF decorations (setDefaultLookAndFeelDecorated(true))


luck, db
There are no new questions, but there may be new answers.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Darryl Burke wrote:
a number of colors on the UI change. So far so good.

Some of the colors on the UI, however, do not change.

Have you gone through Changing the Look and Feel After Startup?
[/quote=Darryl Burke]

Yes, that is how I got some of the colors to change. And I am changing the outermost container, so the colors that aren't changing are still within the container.

Darryl Burke wrote:
one of them claims to be the color for title bar captions when they are active, another claims to be the color for the color of the window border, but I can't get any change to the UI by setting either of those colors.

Sounds like you're not using the LaF decorations (setDefaultLookAndFeelDecorated(true))


You were right -- setting that got a couple of other things to change (window decorations, e.g.), but still not all of them. I'm still missing changes to the background text for the menu and toolbar, for instance.

Does anyone know where definitions of these colors might be? I was surprised when I couldn't find them in the java documentation for this method, or a pointer to them or something.

rc
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

Check out Rob Camick's UIManager Defaults. Note that the settings are part of certain LaFs and are not documented API, so don't expect all combinations to work with all LaFs.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Also that array looks very peculiar. It looks like something which ought to be put in a Map.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

That's probably what table.putDefaults does.

It would probably be more in line with Swing design to write a custom Theme extending DefaultMetalTheme or its subclass OceanTheme.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Darryl Burke wrote:That's probably what table.putDefaults does. . . . .
You're correct.
 
Don't get me started about those stupid light bulbs.
 
subject: Changing colors on my swing app