http://s019.radikal.ru/i626/1203/ae/8420ef7757f7.png
JScrollPane.getVerticalScrollBar().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("mouseClicked");
}
public void mousePressed(MouseEvent e) {
System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent e) {
System.out.println("mouseReleased");
}
});
It works if I click on the strip, but does not work when I click on the buttons
The buttons are defined in the JScrollBar's UI so you need to extend the default UI implementation. Of course it is platform dependent. In my example I'll show you how to do it with
BasicScrollBarUI
. You can define a custom JScrollBar by calling theJScrollPane.setVerticalScrollBar(new CustomScrollBar());
In your CustomScrollBar you can do the following:I've tested it under XP but without a
JScrollPane
. I hope it helps!