Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determine appearance settings



Manuel Hermann <email@hidden> wrote:

>Is there an easy way for a customized swing component to determine the user
>appearance settings of the System Preferences (Blue / Graphite)?
>
>The aqua look&feel reacts immediately when changing the settings in the
>preferences. I want my customized swing controls to behave the same way.

You could render a JComponent that has color in an offscreen BufferedImage,
then examine the resulting pixels for hue. You'll want to use something
like the knob of a JSlider that's easy to grab pixels from, and whose color
definitely tracks the system state.

I have not tried this using JComponents, but it does work with the
hilite-color (SystemColor.textHighlight).

I'd say the ickiest part of all this is that you don't receive any event to
tell you when the color changes. So you have to poll if you want to track
the change in something close to real-time. That may affect your
interpretation of "easy".

There may be another way, but you'd probably have to dig inside the Aqua
PLAF UI-delegates to figure out how things like JSlider learn about the
change and flip their appearance. If you found out, it would be
unsupported, and could well change with every version of Java that Apple
releases, past or future.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.