Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #210

Re: JSlider Set knob Colo

From "Leitão" <¶ év‰ï@THRWHITE.remove-dii-this>
Subject Re: JSlider Set knob Colo
Message-ID <1164673389.007931.164770@h54g2000cwb.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1164368819.019130.301150@45g2000cws.googlegroups.com>
Date 2011-04-27 15:26 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Bart...Thanks for your answer...it really worked for me. Hey...Where
did you find this properties like "Slider.gradient" and
"Slider.focusGradient". Do you know some place where I can get all the
properties I can set like this.

Thanks again,

                    Carlos

Bart Cremers escreveu:

> Leitão wrote:
> > Hi,
> >
> >      I would like to change the JSlider's knob color. I saw an  example
> > on the web that used the BasicSliderUI to do that, but it doesn't work
> > well. When I use that it paints correctly the Slider but the rest of
> > the window components are not painted.
> >     You can see the code I am using below:
> >
> >  <snip>
> >
> > Please if anyone has an idea of what is the problem please let me
> > know...I am using java 1.5_07
> >
> > Thanks in advance,
> >
> >                           Carlos Leitao
>
> Hi,
>
> I do not get the problem you've got. All components seem to paint
> correctly, so the problem you've got could be in another area of your
> code.
>
> Besides that, it's possible to change the color of the knob by simply
> overriding some UIDefaults values. You could do the following:
>
>     java.util.List sliderGradient = Arrays.asList(new Object[] {
>         new Float(.3f),
>         new Float(.3f),
>         new ColorUIResource(0xC8DDF2),
>         new Color(0x1b, 0x70, 0xe1),
>         new ColorUIResource( 0x2b, 0x80, 0xF1 )
>     });
>
>     UIManager.getDefaults().put("Slider.gradient", sliderGradient);
>     UIManager.getDefaults().put("Slider.focusGradient",
> sliderGradient);
>
> This way you don't have to implement your own UI.
>
> Note that this will work for the MetalLookAndFeel. Other L&F's might
> require other settings to change it. 
> 
> Regards,
> 
> Bart

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

JSlider Set knob Color "Leitão" <¶év‰ï@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
  Re: JSlider Set knob Colo "Bart Cremers" <bart.cremers@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: JSlider Set knob Colo "Leitão" <¶év‰ï@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
      Re: JSlider Set knob Colo "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000

csiph-web