Hi All,
I need to put an image over jslider's knob image when mouse is present over the knob's image.
I have done something like this.:
slider = new Slider();
s= new mySliderUI(slider ,"slider.png" );
slider.setUI(s);
slider.addMouseListener(new MyMouseAction());
public class MyMouseAction implements MouseListener{
public void mouseEntered(MouseEvent e) {
try {
s.knobImage = ImageIO.read(new File("slider_roll.png"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
public void mouseExited(MouseEvent e) {
try {
s.knobImage = ImageIO.read( new File("slider.png"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
private class mySliderUI extends BasicSliderUI {
Image knobImage;
public mySliderUI( JSlider aSlider, String fileName ) {
super( aSlider );
aSlider.setPaintTrack(false);
aSlider.setBorder(null);
try {
this.knobImage = ImageIO.read( new File(fileName) );
} catch ( IOException e ) {
e.printStackTrace();
}
}
public void paintThumb(Graphics g) {
g.drawImage( this.knobImage, thumbRect.x, thumbRect.y, 10, 15, null );
}
}
The above code is not working. Please tell me how can i do this.
Thanks Jyoti