• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Changing colors on my swing app

 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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))
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also that array looks very peculiar. It looks like something which ought to be put in a Map.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:That's probably what table.putDefaults does. . . . .

You're correct.
 
reply
    Bookmark Topic Watch Topic
  • New Topic