Hi Sean,
Thanks for the attempt but I think there is a problem there. The slider can be moved without using a mouse, i.e. with the keyboard. Handling all those events is quite a convoluted method to achieve the result.
I tried out the following code - this time using a JScrollBar which supports a AdjustmentListener.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class TestScroll extends JFrame {
public TestScroll(){
Container cp = getContentPane();
JScrollBar sb = new JScrollBar();
cp.add(sb, BorderLayout.EAST);
sb.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent e){
JScrollBar jsb = (JScrollBar) e.getAdjustable();
if (!jsb.getValueIsAdjusting())
System.out.println("Value: "+ jsb.getValue());
else System.out.println("Still moving");
}
});
}
public static void main(
String args[]){
TestScroll t = new TestScroll();
t.pack();
t.show();
}
}
It works just the way I want it. But it works with the wrong component. Pls see if you can get a similar functionality for me with the JSlider.
Regds
Sathish