デスクトップペインとjscrollbarがあるnetbeansプラットフォーム(netbeansモジュール)でデスクトップアプリケーションを開発しています。MouseWheelListenerを実装し、追加しました
scrollBar.addMouseWheelListener(this);
クラスのコンストラクターで。今、私がマウスのホイールをスクロールしているとき、私は値を取得していますが、スクロールバーをスクロールしません
private void scrollBarMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
System.out.println("mouse value is------------ " + evt.paramString());
}
上記のsoutの出力は
mouse value is------------ MOUSE_WHEEL,(8,49),absolute(0,0),button=0,clickCount=0,scrollType=WHEEL_UNIT_SCROLL,scrollAmount=3,wheelRotation=1
jscrollbarでmosuewheelイベントを有効にするにはどうすればよいですか?
検索しましたが、スクロールペインのイベントが見つかりましたが、明示的にスクロールバーを探しています。
私は余分なコードを削除し、次のサンプルコードで探しているものを示しました
public final class ScrollableWindow1TopComponent extends TopComponent implements ComponentListener, MouseWheelListener {
private javax.swing.JScrollBar scrollBar;
private javax.swing.JDesktopPane scrollableGraphnewContainer;
public ScrollableWindow1TopComponent() {
this.addComponentListener(this);
scrollBar.addMouseWheelListener(this);
}
private void scrollBarMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
System.out.println("mouse value is------------ " + evt.paramString());
}
private void scrollBarAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
//code that works fine
}
}