There is one JPanel
with attached MouseWheelListener
. This panel has on top several other JPanels, and completely occupies parent JPanel
area. I want to know if MouseWheelListener
can receive events when the mouse is over this parent JPanel
. If I attach MouseListener
to parent JPanel
- it is not receiving any events, because on top of it there are several other JPanels.
Maybe there is some method to find out when MouseWheelListener
can receive events? I mean like if you standing on JScrollPane
- only then you can move the scrollbar (and it is not important how many JPanels on it).
EDIT:
The AWTEventListener
didn't helped also - the upper JPanels still blocking parent JPanel events.. :
AWTEventListener awt = new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent e) {
if (MouseEvent.MOUSE_ENTERED == e.getID()) {
MouseEvent event = (MouseEvent) e;
for (Component c : getComponents()) {//get all parent JPanel components
if (event.getComponent().equals(c)) {
active = true;
scrollBar.repaint();
break;
}
}
} else if (MouseEvent.MOUSE_EXITED == e.getID()) {
MouseEvent event = (MouseEvent) e;
for (Component c : getComponents()) {
if (event.getComponent().equals(c)) {
active = false;
scrollBar.repaint();
break;
}
}
}
}
};
Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
Perhaps it is impossible to achieve that..