If i have something like this, where i can control the auto-scrolling using boolean flag "performAdjustment":
static boolean performAdjustment = true;
JTextArea textArea = new JTextArea();
JScrollPane jScrollPane1 = new JScrollPane(textArea);
jScrollPane1.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
if(performAdjustment){
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
}
}});
Now i this works fine, but the problem is i want to unset this boolean flag when a user clicks on the scroll bar and it should be set again when the user leave the click (like onMouseOut event in JavaScript).
Can you tell me how can i add this new EventListener where i can detect click event of the scroll bar??