I have a java.awt.Scrollbar component on applet.
I need to perform actions when user releases the mouse from the
scrollbar. For example the user presses the mouse on the scrollbars
tracking rectangle and starts to track. Then the values of the
scrollbar changes and finally user releases the mouse left button-
this final event (mouse release) is in my interest. How can i get
mouse release event from scrollbar? The AdjustmentListener does not
suit for me because it fires AdjustmentEvents even then when the user
hasn't released the mouse. I need to perform more actions for every
scrollbar's change; so my applet i slow at the moment, because every
"tracking in scrollbar" creates a lot of events before the mouse is
finally released.
I added a MouseListener for my scrollbar, but mouseReleased event does
not work. Can yo help me?
Here is some demo code i tried:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Kerimisriba1 extends Applet implements
AdjustmentListener, MouseListener{
Scrollbar kerimisriba=new Scrollbar(Scrollbar.VERTICAL, 20, 5, 1,
100); //algväärtus, nupu suurus, vähim ja suurim väärtus
TextField tf=new TextField(10);
public Kerimisriba1(){
setLayout(new BorderLayout());
add(kerimisriba, BorderLayout.WEST);
add(tf, BorderLayout.SOUTH);
//kerimisriba.addAdjustmentListener(this);
kerimisriba.addMouseListener(this);
System.out.println("AdjustmentEvent.TRACK="+AdjustmentEvent.TRACK);
}
public void adjustmentValueChanged(AdjustmentEvent e){
//System.out.println(e.getAdjustmentType());
// tf.setText(kerimisriba.getValue()+"");
}
public void mouseReleased(MouseEvent me){
tf.setText("mouseReleased");
}
public void mouseClicked(MouseEvent me){}
public void mouseEntered(MouseEvent me){}
public void mouseExited(MouseEvent me){}
public void mousePressed(MouseEvent me){}
}