Here's how I would do it.  Its by no means the only way, so
if anybody has something to add/subtract from this, feel free.

Anyway, I wouldn't mess with the JSlider.  Instead, the way
I would do it is something like this:

public class SteeringWheel extends JPanel {
     AffineTransform currentRotation=new AffineTranform().;
     ImageIcon wheelImage=new ImageIcon("wheel.gif");

     public int getRotationDegrees() {
          // may need to dust off the old trig book for this one ;)
     }

     public void paint(Graphics g) {
          Graphics2D g2d=(Graphics2D)g;
          g2d.drawImage(wheelImage,currentRotation,this);
     }

};

Then just have that guy either implement a MouseListener or MouseAdapter,
(whichever you prefer) and those functions should call
currentRotation.rotate(theta);
when the component is "dragged".

I hope this helps,
-KC





Perico Perez <[EMAIL PROTECTED]> on 10/31/2001 05:10:42 AM

Sent by:  Perico Perez <[EMAIL PROTECTED]>


To:   [EMAIL PROTECTED]
cc:    (KC Eilander/MTN/US/3Com)
Subject:  Rounded JSlider.



Hello,

I need to build something similar to a JSlider but rounded (to represent

a wheel that drives a car). Anybody have some idea about how can I do
that? (some orientation would be greatly appreciated).

Thanks a lot


X-Mozilla-Status2: 00000000
Message-ID: <[EMAIL PROTECTED]>
Date: Wed, 31 Oct 2001 12:48:29 +0100
From: Perico Perez <[EMAIL PROTECTED]>
Organization: None
X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.7 sun4u)
X-Accept-Language: en
MIME-Version: 1.0
To: [EMAIL PROTECTED]
Subject: Rounded JSlider.
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Hello,

I need to build something similar to a JSlider but rounded (to represent
a wheel that drives a car). Anybody have some idea about how can I do
that? (some orientation would be greatly appreciated).

Thanks a lot







_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to