List of usage examples for java.awt.event MouseWheelListener mouseWheelMoved
public void mouseWheelMoved(MouseWheelEvent e);
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); glassPane.setOpaque(false);/*from www.j a v a 2 s.co m*/ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); for (int i = 0; i < 14000; i++) { DefaultMutableTreeNode node = new DefaultMutableTreeNode("Root" + i); node.add(new DefaultMutableTreeNode("Child" + i)); root.add(node); } final JTree tree = new JTree(root); tree.setRootVisible(false); final JScrollPane pane = new JScrollPane(tree); add(pane); JButton button = new JButton("Expand"); button.addActionListener(e -> { Thread t = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } TreePath[] paths = tree.getSelectionPaths(); if (paths == null || paths.length == 0) { glassPane.setVisible(false); return; } tree.setSelectionPath(paths[0]); for (int i = 0; i < paths.length; i++) { tree.expandPath(paths[i]); } glassPane.setVisible(false); } }); getRootPane().setGlassPane(glassPane); glassPane.setVisible(true); t.start(); }); add(button); glassPane.addMouseWheelListener(e -> { for (MouseWheelListener mwl : pane.getMouseWheelListeners()) { mwl.mouseWheelMoved(e); } }); }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public void processMouseWheelEvent(MouseWheelEvent event) { if (isMouseWheelEnabled) { for (MouseWheelListener listener : getMouseWheelListeners()) { listener.mouseWheelMoved(event); }/*from w w w.ja v a 2 s .c o m*/ } }