Article View: borland.public.jbuilder.java.swing
Article #7746Re: Customized slider knob imagery
From: Lars Thuring
Date: Sat, 06 Jan 2001 23:10
Date: Sat, 06 Jan 2001 23:10
57 lines
2528 bytes
2528 bytes
Cool!
It works nicely (without any changes)! Thank you.
Lars
Torsten Welches wrote:
> Lars,
>
> JSlider uses a swing.plaf.SliderUI subclass to render the component.
> SliderUI itself is an empty abstract class, but the basic non-abstract child
> class BasicSliderUI has a public method paintThumb(Graphics g) that you
> could override.
>
> Because of the pluggable L&F feature there is more than one "real" SliderUI
> (Metal, Windows ...), all of which inherit from BasicSliderUI. That makes is
> more complicated (you have to register your SliderUI with the UIManager and
> so on)
>
> Here's an "non-production-quality" example that draws the thumb as a red
> cycle:
>
> class MySliderUI extends javax.swing.plaf.basic.BasicSliderUI {
> public MySliderUI(JSlider s) {
> super(s);
> }
> public void paintThumb(Graphics g) {
> g.setColor(Color.red);
> g.fillOval(thumbRect.x, thumbRect.y, thumbRect.width,
> thumbRect.height);
> }
> protected Dimension getThumbSize() {
> return new Dimension(15, 15);
> }
> }
>
> Use it like that:
>
> Slider slider = new JSlider();
> slider.setUI(new MySliderUI(slider));
>
> Viel Gl�ck,
> Torsten
>
> Lars Thuring schrieb in Nachricht <3A567ADC.25868A32@t-online.de>...
> >Hi list,
> >
> >is there some convenient way of having your own images painted instead
> >of the standard JSlider knobs? Or is the proper way overiding
> >paintComponent(), finding out where the knob is and paint your image on
> >top of it?
> >
> >Thanks in advance.
> >
> >Lars
Technical Details
Message-ID:
<3A57A5E1.10B75D6B@t-online.de>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!news.tele.dk!194.213.69.151!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!62.226.249.74References:
<3A567ADC.25868A32@t-online.de> <3a56f931$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,f6e07f74041fb29d X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2001-01-06 15:14:21 PST Message-ID: <3A57A5E1.10B75D6B@t-online.de> Date: Sun, 07 Jan 2001 00:10:25 +0100 From: Lars Thuring <thuring@t-online.de> X-Mailer: Mozilla 4.71 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: Customized slider knob imagery References: <3A567ADC.25868A32@t-online.de> <3a56f931$1_1@dnews> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 62.226.249.74 X-Trace: 6 Jan 2001 15:07:18 -0800, 62.226.249.74 Lines: 58 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!news.tele.dk!194.213.69.151!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!62.226.249.74