Reputation: 185
I have a jFrame
along with jScrollPane
in this jScrollPane
there are few other component such as jTextField
jTextArea
jTable
etc.. (this form I have designed with NetBeans form designer)
jScrollPane
(the Parent Component) has vertical scroll bar and it scroll with the mouse wheel. But when mouse move on a jTextArea
or a jTable
(they have there own scroll bars) Mouse Wheel focus goes to them and scrolling them instead of scrolling jScrollPane
. I want to keep scroll focus on jScrollPane
without going it to any other component in it.
Upvotes: 0
Views: 272
Reputation: 427
I did this in my panel and it worked...
jScrollPane1.removeMouseWheelListener(jScrollPane1.getMouseWheelListeners()[0]);
Upvotes: 1
Reputation: 185
scrollPane = new JScrollPane() {
@Override
protected void processMouseWheelEvent(MouseWheelEvent e) {
if (!isWheelScrollingEnabled()) {
if (getParent() != null)
getParent().dispatchEvent(
SwingUtilities.convertMouseEvent(this, e, getParent()));
return;
}
super.processMouseWheelEvent(e);
}
};
scrollPane.setWheelScrollingEnabled(false);
Upvotes: 1