Java 类java.awt.event.MouseWheelListener 实例源码

项目:incubator-netbeans    文件:UIUtils.java   
public static void issue163946Hack(final JScrollPane scrollPane) {
    MouseWheelListener listener = new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (scrollPane.getVerticalScrollBar().isShowing()) {
                if (e.getSource() != scrollPane) {
                    e.setSource(scrollPane);
                    scrollPane.dispatchEvent(e);
                }
            } else {
                scrollPane.getParent().dispatchEvent(e);
            }
        }
    };
    scrollPane.addMouseWheelListener(listener);
    scrollPane.getViewport().getView().addMouseWheelListener(listener);
}
项目:HmiCore    文件:MorphPanel.java   
public MorphPanel(String morphName, final MorphView morphView) {
        this.morphName = morphName;
        this.morphView = morphView;
        this.mouseWheelListener = new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent arg0) {
                if (arg0.getSource() instanceof JSlider) {
//                  JSlider slider = (JSlider) arg0.getSource();
//                  slider.setValue(slider.getValue() + arg0.getUnitsToScroll());
                }
            }
        };
        panel.setLayout(new BoxLayout(panel,BoxLayout.LINE_AXIS));
        undoButton = new JButton();
        panelState = new State();
        morphSlider = new JSlider(JSlider.HORIZONTAL, -100, 100, 0);

        setupLabel(morphName);
        setupSlider();
        useInKeyFrameCheckBox = new JCheckBox();
        setupCheckbox(useInKeyFrameCheckBox);
        setupUndoButton();
    }
项目:scelight    文件:MapCanvas.java   
/**
 * Creates a new {@link MapCanvas}.
 * 
 * @param repProc replay processor
 * @param zoomComboBox combo box which tells how to zoom the map image
 */
public MapCanvas( final RepProcessor repProc, final XComboBox< Zoom > zoomComboBox ) {
    this.repProc = repProc;
    this.zoomComboBox = zoomComboBox;

    ricon = MapImageCache.getMapImage( repProc );

    GuiUtils.makeComponentDragScrollable( this );

    // Zoom in and out with CTRL+wheel scroll:
    addMouseWheelListener( new MouseWheelListener() {
        @Override
        public void mouseWheelMoved( final MouseWheelEvent event ) {
            if ( event.isControlDown() ) {
                final int newZoomIdx = zoomComboBox.getSelectedIndex() - event.getWheelRotation();
                zoomComboBox.setSelectedIndex( Math.max( 0, Math.min( zoomComboBox.getItemCount() - 1, newZoomIdx ) ) );
                // An event will be fired which will cause reconfigureZoom() to be called...
            }
        }
    } );
}
项目:CMMParser    文件:MainFrame.java   
/**
 * 初始化语法错误面板
 */
private void initGrammarErrorPane() {
    grammarErrorPanel = new GrammarErrorPanel(sourceCodeEditorPane);
    grammarErrorPanel.setBackground(LIGHT_GRAY_COLOR);
    grammarErrorScroll = new JScrollPane(grammarErrorPanel);
    grammarErrorScroll.setLocation(GRAMMAR_START_X, GRAMMAR_START_Y);
    grammarErrorScroll.setSize(GRAMMAR_WIDTH, GRAMMAR_HEIGHT);
    this.add(grammarErrorScroll);
    final JScrollBar vBar = grammarErrorScroll.getVerticalScrollBar();
    vBar.setUI(null);
    grammarErrorScroll.setHorizontalScrollBar(null);
    grammarErrorScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    MouseWheelListener[] listeners = grammarErrorScroll.getMouseWheelListeners();
    for (MouseWheelListener l : listeners) {
        grammarErrorScroll.removeMouseWheelListener(l);
    }
    grammarErrorScroll.setBorder(null);
}
项目:Net2Plan    文件:JScrollPopupMenu.java   
public JScrollPopupMenu(String label)
{
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener()
    {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event)
        {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL)
                    ? event.getUnitsToScroll() * scrollBar.getUnitIncrement()
                    : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
项目:jailer    文件:JScrollC2PopupMenu.java   
public JScrollC2PopupMenu(String label) {
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event) {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event
                    .getUnitsToScroll() * scrollBar.getUnitIncrement()
                    : (event.getWheelRotation() < 0 ? -1 : 1)
                            * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
项目:jailer    文件:JScrollPopupMenu.java   
public JScrollPopupMenu(String label) {
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event) {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event
                    .getUnitsToScroll() * scrollBar.getUnitIncrement()
                    : (event.getWheelRotation() < 0 ? -1 : 1)
                            * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
项目:AppWoksUtils    文件:JScrollPopupMenu.java   
public JScrollPopupMenu(String label) {
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event) {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
项目:openwonderland    文件:Window2D.java   
/**
 * Remove a listener for mouse wheel events.
 *
 * @param listener The mouse wheel listener to remove.
 */
public void removeMouseWheelListener(MouseWheelListener listener) {
    if (app == null) {
        return;
    }
    synchronized (app.getAppCleanupLock()) {
        synchronized (this) {
            if (mouseWheelListeners == null) {
                return;
            }
            mouseWheelListeners.remove(listener);
            if (mouseWheelListeners.size() == 0) {
                mouseWheelListeners = null;
            }
        }
    }
}
项目:rplib    文件:ImagePanel.java   
public void setModel(ImagePanelModel model) {
    this.model = model;
    revalidate();
    final JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this);

    if (scrollPane != null) {
        scrollPane.addMouseWheelListener(new MouseWheelListener() {
            public void mouseWheelMoved(MouseWheelEvent e) {
                if (SwingUtil.isControlDown(e) || e.isMetaDown()) {
                    e.consume();
                    int steps = e.getWheelRotation();
                    setGridSize(gridSize + steps);
                    scrollPane.setWheelScrollingEnabled(false);
                } else {
                    scrollPane.setWheelScrollingEnabled(true);
                }
            }
        });

        scrollPane.revalidate();
        scrollPane.repaint();
    }
}
项目:cn1    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:cn1    文件:ScrollPaneTest.java   
public final void testProcessMouseWheelEvent() {
    eventProcessed = false;
    scrollPane.addMouseWheelListener(new MouseWheelListener() {

        public void mouseWheelMoved(MouseWheelEvent arg0) {
            eventProcessed = true;
        }

    });

    scrollPane.processEvent(new MouseWheelEvent(scrollPane,
                                          MouseEvent.MOUSE_WHEEL,
                                          0l, 0, 100, 200, 0, false,
                                          MouseWheelEvent.WHEEL_BLOCK_SCROLL,
                                          10, 10));
    assertTrue(eventProcessed);
}
项目:magarena    文件:ImageCardListViewer.java   
private void setMouseWheelListener() {
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event) {
            final int cardIndex = getCardIndexAt(event.getX(), event.getY());
            if (event.getWheelRotation() < 0) { // rotate mousewheel forward
                if (cardIndex >= 0) {
                    showCardPopup(cardIndex);
                }
            } else if (event.getWheelRotation() > 0) { // rotate mousewheel back
                if (cardIndex >= 0) {
                    controller.hideInfo();
                }
            }
        }
    });
}
项目:UiL-OTS-Video-Coding-System    文件:ABar.java   
private void registerScrollWheelListener(){
    this.addMouseWheelListener(new MouseWheelListener(){
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if(e.getModifiers() == InputEvent.CTRL_MASK){
                long centerTime = ABar.this.timeByXinView(e.getPoint().x);
                long newVisibleTime = navbar.getVisibleTime() + navbar.getVisibleTime() / 10 * e.getWheelRotation();
                if(newVisibleTime <= player.getMediaDuration() && newVisibleTime > 100)
                    navbar.setVisibleTime(newVisibleTime, centerTime);
                else if(newVisibleTime > player.getMediaDuration()){
                    navbar.setVisibleTime(player.getMediaDuration(), centerTime);
                }
            } else {
                long scrollSpeed = navbar.getVisibleTime() / 10;
                long newTime = navbar.getCurrentStartVisibleTime() + (scrollSpeed * e.getWheelRotation());
                navbar.setCurrentStartVisibleTime(newTime);
            }
        }
    });
}
项目:unravl    文件:UnRAVLFrame.java   
public void addZoomMouseListeners() {
    MouseWheelListener zoomer = new java.awt.event.MouseWheelListener() {
        public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
            onZoom(evt);
        }
    };

    for (JTextArea ta : textAreas) {
        // Note: We cannot add a MouseWheelListener to the JTextArea; the
        // JScrollPane
        // will disable it's scrolling handler of the child has a mouse
        // listener.
        // So walk from the JtextArea to JViewPort to JScrollPane and add
        // the listeners there.
        if (ta.getParent().getParent() instanceof JScrollPane) {
            JScrollPane parent = (JScrollPane) ta.getParent().getParent();
            parent.addMouseWheelListener(zoomer);
        }
    }
}
项目:BfROpenLab    文件:VisualizationViewer.java   
/**
 * a setter for the GraphMouse. This will remove any
 * previous GraphMouse (including the one that
 * is added in the initMouseClicker method.
 * @param graphMouse new value
 */
public void setGraphMouse(GraphMouse graphMouse) {
    this.graphMouse = graphMouse;
    MouseListener[] ml = getMouseListeners();
    for(int i=0; i<ml.length; i++) {
        if(ml[i] instanceof GraphMouse) {
            removeMouseListener(ml[i]);
        }
    }
    MouseMotionListener[] mml = getMouseMotionListeners();
    for(int i=0; i<mml.length; i++) {
        if(mml[i] instanceof GraphMouse) {
            removeMouseMotionListener(mml[i]);
        }
    }
    MouseWheelListener[] mwl = getMouseWheelListeners();
    for(int i=0; i<mwl.length; i++) {
        if(mwl[i] instanceof GraphMouse) {
            removeMouseWheelListener(mwl[i]);
        }
    }
    addMouseListener(graphMouse);
    addMouseMotionListener(graphMouse);
    addMouseWheelListener(graphMouse);
}
项目:com.opendoorlogistics    文件:JScrollPopupMenu.java   
public JScrollPopupMenu(String label) {
    super(label);
    setLayout(new ScrollPopupMenuLayout());

    super.add(getScrollBar());
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent event) {
            JScrollBar scrollBar = getScrollBar();
            int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();

            scrollBar.setValue(scrollBar.getValue() + amount);
            event.consume();
        }
    });
}
项目:freeVM    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:freeVM    文件:ScrollPaneTest.java   
public final void testProcessMouseWheelEvent() {
    eventProcessed = false;
    scrollPane.addMouseWheelListener(new MouseWheelListener() {

        public void mouseWheelMoved(MouseWheelEvent arg0) {
            eventProcessed = true;
        }

    });

    scrollPane.processEvent(new MouseWheelEvent(scrollPane,
                                          MouseEvent.MOUSE_WHEEL,
                                          0l, 0, 100, 200, 0, false,
                                          MouseWheelEvent.WHEEL_BLOCK_SCROLL,
                                          10, 10));
    assertTrue(eventProcessed);
}
项目:freeVM    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:freeVM    文件:ScrollPaneTest.java   
public final void testProcessMouseWheelEvent() {
    eventProcessed = false;
    scrollPane.addMouseWheelListener(new MouseWheelListener() {

        public void mouseWheelMoved(MouseWheelEvent arg0) {
            eventProcessed = true;
        }

    });

    scrollPane.processEvent(new MouseWheelEvent(scrollPane,
                                          MouseEvent.MOUSE_WHEEL,
                                          0l, 0, 100, 200, 0, false,
                                          MouseWheelEvent.WHEEL_BLOCK_SCROLL,
                                          10, 10));
    assertTrue(eventProcessed);
}
项目:clickwatch    文件:VisualizationViewer.java   
/**
 * a setter for the GraphMouse. This will remove any
 * previous GraphMouse (including the one that
 * is added in the initMouseClicker method.
 * @param graphMouse new value
 */
public void setGraphMouse(GraphMouse graphMouse) {
    this.graphMouse = graphMouse;
    MouseListener[] ml = getMouseListeners();
    for(int i=0; i<ml.length; i++) {
        if(ml[i] instanceof GraphMouse) {
            removeMouseListener(ml[i]);
        }
    }
    MouseMotionListener[] mml = getMouseMotionListeners();
    for(int i=0; i<mml.length; i++) {
        if(mml[i] instanceof GraphMouse) {
            removeMouseMotionListener(mml[i]);
        }
    }
    MouseWheelListener[] mwl = getMouseWheelListeners();
    for(int i=0; i<mwl.length; i++) {
        if(mwl[i] instanceof GraphMouse) {
            removeMouseWheelListener(mwl[i]);
        }
    }
    addMouseListener(graphMouse);
    addMouseMotionListener(graphMouse);
    addMouseWheelListener(graphMouse);
}
项目:jadx    文件:TabbedPane.java   
TabbedPane(MainWindow window) {
    mainWindow = window;

    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            int direction = e.getWheelRotation();
            int index = getSelectedIndex();
            int maxIndex = getTabCount() - 1;
            if ((index == 0 && direction < 0)
                    || (index == maxIndex && direction > 0)) {
                index = maxIndex - index;
            } else {
                index += direction;
            }
            setSelectedIndex(index);
        }
    });
}
项目:IDDEA    文件:JHotDrawInteractiveDisplay2D.java   
/**
    * Add new event handler. Depending on the interfaces implemented by
    * <code>handler</code> calls {@link Component#addKeyListener(KeyListener)},
    * {@link Component#addMouseListener(MouseListener)},
    * {@link Component#addMouseMotionListener(MouseMotionListener)},
    * {@link Component#addMouseWheelListener(MouseWheelListener)}.
    */
   @Override
public void addHandler( final Object handler )
   {
       if ( KeyListener.class.isInstance( handler ) )
           addKeyListener( ( KeyListener ) handler );

       if ( MouseMotionListener.class.isInstance( handler ) )
           addMouseMotionListener( ( MouseMotionListener ) handler );

       if ( MouseListener.class.isInstance( handler ) )
           addMouseListener( ( MouseListener ) handler );

       if ( MouseWheelListener.class.isInstance( handler ) )
           addMouseWheelListener( ( MouseWheelListener ) handler );
   }
项目:IDDEA    文件:JHotDrawInteractiveDisplay2D.java   
/**
    * Remove an event handler.
    * Add new event handler. Depending on the interfaces implemented by
    * <code>handler</code> calls {@link Component#removeKeyListener(KeyListener)},
    * {@link Component#removeMouseListener(MouseListener)},
    * {@link Component#removeMouseMotionListener(MouseMotionListener)},
    * {@link Component#removeMouseWheelListener(MouseWheelListener)}.
    */
   @Override
public void removeHandler( final Object handler )
   {
       if ( KeyListener.class.isInstance( handler ) )
           removeKeyListener( ( KeyListener ) handler );

       if ( MouseMotionListener.class.isInstance( handler ) )
           removeMouseMotionListener( ( MouseMotionListener ) handler );

       if ( MouseListener.class.isInstance( handler ) )
           removeMouseListener( ( MouseListener ) handler );

       if ( MouseWheelListener.class.isInstance( handler ) )
           removeMouseWheelListener( ( MouseWheelListener ) handler );
   }
项目:jdotxt    文件:JdotxtGUI.java   
@Override
public void mouseWheelMoved(MouseWheelEvent originalEvent) {
    MouseWheelEvent event = new MouseWheelEvent( originalEvent.getComponent(),
                                                 originalEvent.getID(),
                                                 originalEvent.getWhen(),
                                                 originalEvent.getModifiers(),
                                                 originalEvent.getX(),
                                                 originalEvent.getY(),
                                                 originalEvent.getXOnScreen(),
                                                 originalEvent.getYOnScreen(),
                                                 originalEvent.getClickCount(),
                                                 originalEvent.isPopupTrigger(),
                                                 originalEvent.getScrollType(),
                                                 scrollAmount,
                                                 originalEvent.getWheelRotation());
    for (MouseWheelListener listener : originalListeners) listener.mouseWheelMoved(event);
}
项目:NK-VirtualGlobe    文件:AWTDeviceFactory.java   
/**
 * Return the array of DeviceManagers that are available per the
 * constructor parameters. The InputDevices instantiated will be
 * initialized with the AWT ui toolkit event listeners.
 *
 * @return the array of DeviceManagers. If no DeviceManagers are
 * available, an empty (size 0) array is returned.
 */
public DeviceManager[] getDeviceManagers( ) {
    List managerList = createDevices( );
    DeviceManager[] manager =
        (DeviceManager[])managerList.toArray( new DeviceManager[managerList.size( )] );
    Component cmp = (Component)canvas;
    for( int i = 0; i < manager.length; i++ ) {
        InputDevice[] device = manager[i].getDevices( );
        for( int j = 0; j < device.length; j++ ) {
            InputDevice dev = device[j];
            if( dev instanceof MouseListener ) {
                cmp.addMouseListener( (MouseListener)dev );
            }
            if( dev instanceof MouseMotionListener ) {
                cmp.addMouseMotionListener( (MouseMotionListener)dev );
            }
            if( dev instanceof MouseWheelListener ) {
                cmp.addMouseWheelListener( (MouseWheelListener)dev );
            }
            if( dev instanceof KeyListener ) {
                cmp.addKeyListener( (KeyListener)dev );
            }
        }
    }
    return( manager );
}
项目:litiengine    文件:Mouse.java   
@Override
public void registerMouseWheelListener(final MouseWheelListener listener) {
  if (this.mouseWheelListeners.contains(listener)) {
    return;
  }

  this.mouseWheelListeners.add(listener);
}
项目:litiengine    文件:Mouse.java   
@Override
public void unregisterMouseWheelListener(final MouseWheelListener listener) {
  if (!this.mouseWheelListeners.contains(listener)) {
    return;
  }

  this.mouseWheelListeners.remove(listener);
}
项目:incubator-netbeans    文件:DocumentViewOp.java   
private void updateListeners() {
    ScrollPaneUI ui = scrollPane.getUI();
    if (ui != lastUI) {
        // Update "ui" property listener
        if (ui != null) {
            // Check mouse wheel listeners on scroll pane.
            // Pair first non-MWDelegator listener with 
            // Remove any other delegators than this one.
            MouseWheelListener[] mwls = scrollPane.getListeners(MouseWheelListener.class);
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "MouseWheelDelegator.updateListeners(): scrollPane change scrollPane={0}, MouseWheelListeners:{1}\n",
                        new Object[]{obj2String(scrollPane), Arrays.asList(mwls)});
            }
            delegateListener = null;
            for (MouseWheelListener listener : mwls) {
                if (listener instanceof MouseWheelDelegator) {
                    scrollPane.removeMouseWheelListener(listener);
                    if (delegateListener == null) {
                        delegateListener = ((MouseWheelDelegator) listener).delegateListener;
                        scrollPane.addMouseWheelListener(this);
                    }
                } else { // Regular listener 
                    // Current patch only assumes one MW listener attached by the UI impl.
                    if (delegateListener == null) {
                        delegateListener = listener;
                        scrollPane.removeMouseWheelListener(listener);
                        scrollPane.addMouseWheelListener(this);
                    }
                }
            }
        }
        lastUI = ui;
    }
}
项目:incubator-netbeans    文件:DocumentViewOp.java   
void delegateToOriginalListener(MouseWheelEvent e, JScrollPane activeScrollPane) {
    // Only delegate if the updated scrollpane is still actively used by the DocumentViewOp
    // and when it still uses the overriden listener (this)
    if (activeScrollPane == scrollPane) {
        MouseWheelListener[] mwls = scrollPane.getListeners(MouseWheelListener.class);
        for (int i = 0; i < mwls.length; i++) {
            if (mwls[i] == this) {
                delegateListener.mouseWheelMoved(e);
                return;
            }
        }
    }
}
项目:incubator-netbeans    文件:Preview.java   
public void addMouseWheelListener(MouseWheelListener listener) {
            if (myMouseWheelListeners == null) {
                myMouseWheelListeners = new ArrayList<MouseWheelListener>();
            }
//out("Listener: " + listener.getClass().getName());
            myMouseWheelListeners.add(listener);
        }
项目:incubator-netbeans    文件:Preview.java   
public void addWheelListener(MouseWheelListener wheelListener) {
    super.addMouseWheelListener(wheelListener);

    for (int i = 0; i < myMouseWheelListeners.size(); i++) {
        super.addMouseWheelListener(myMouseWheelListeners.get(i));
    }
}
项目:incubator-netbeans    文件:ChartPanel.java   
private void setWheelScrollHandler(final JScrollBar scrollBar) {
    chart.addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            scroll(scrollBar, e);
        }
    });
}
项目:incubator-netbeans    文件:JExtendedSpinner.java   
private void configureWheelListener() {
    addMouseWheelListener(new MouseWheelListener() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) return;
            Object newValue = (e.getWheelRotation() < 0 ?
                               JExtendedSpinner.this.getNextValue() :
                               JExtendedSpinner.this.getPreviousValue());
            if (newValue != null) JExtendedSpinner.this.setValue(newValue);
        }
    });
}
项目:MapAnalyst    文件:JMapController.java   
public JMapController(JMapViewer map) {
    this.map = map;
    if (this instanceof MouseListener)
        map.addMouseListener((MouseListener) this);
    if (this instanceof MouseWheelListener)
        map.addMouseWheelListener((MouseWheelListener) this);
    if (this instanceof MouseMotionListener)
        map.addMouseMotionListener((MouseMotionListener) this);
}
项目:ramus    文件:PrintPreviewComponent.java   
public PrintPreviewComponent(RamusPrintable printable, int columnCount,
                             GUIFramework framework) {
    this.printable = printable;
    this.columnCount = columnCount;
    this.framework = framework;
    MouseWheelListener l = new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                if (e.getModifiers() == KeyEvent.CTRL_MASK) {
                    double r = e.getWheelRotation();
                    double zoom = getZoom() - 0.2 * r;
                    setCurrentZoom(zoom);
                } else {
                    Rectangle rect = getVisibleRect();
                    scrollRectToVisible(new Rectangle(rect.x, rect.y
                            + e.getWheelRotation() * 150, rect.width,
                            rect.height));
                }
            }
        }
    };
    this.addMouseWheelListener(l);
    layout = Options.getInteger("PREVIW_LAYOUT", PREV_LAYOUT_GRID);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
        }
    });
    setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
}
项目:audiveris    文件:Rubber.java   
/**
 * Called when the mouse wheel is moved.
 * If CTRL key is down, modify current zoom ratio accordingly, otherwise
 * forward the wheel event to proper container (JScrollPane usually).
 *
 * @param e the mouse wheel event
 */
@Override
public void mouseWheelMoved (MouseWheelEvent e)
{
    // CTRL is down?
    if (e.isControlDown()) {
        double ratio = zoom.getRatio();

        if (e.getWheelRotation() > 0) {
            ratio /= factor;
        } else {
            ratio *= factor;
        }

        zoom.setRatio(ratio);
    } else {
        // Forward event to some container of the component?
        Container container = component.getParent();

        while (container != null) {
            if (container instanceof JComponent) {
                JComponent comp = (JComponent) container;
                MouseWheelListener[] listeners = comp.getMouseWheelListeners();

                if (listeners.length > 0) {
                    for (MouseWheelListener listener : listeners) {
                        listener.mouseWheelMoved(e);
                    }

                    return;
                }
            }

            container = container.getParent();
        }
    }
}
项目:HmiCore    文件:JointRotationPanel.java   
public JointRotationPanel(String jointName, JointView jointView) {
    this.jointName = jointName;
    this.jointView = jointView;
    this.mouseWheelListener = new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent arg0) {
            if (arg0.getSource() instanceof JSlider) {
                // JSlider slider = (JSlider) arg0.getSource();
                // slider.setValue(slider.getValue() +
                // arg0.getUnitsToScroll());
            }
        }
    };
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    undoButton = new JButton();
    panelState = new State();
    pitchSlider = new JSlider(JSlider.HORIZONTAL, -180, 180, 0);
    yawSlider = new JSlider(JSlider.HORIZONTAL, -180, 180, 0);
    rollSlider = new JSlider(JSlider.HORIZONTAL, -180, 180, 0);
    useInKeyFrameCheckBox = new JCheckBox();
    setupLabel(jointName);
    setupSlider(pitchSlider);
    setupSlider(yawSlider);
    setupSlider(rollSlider);
    setupCheckbox(useInKeyFrameCheckBox);

    setupUndoButton();
}
项目:PhET    文件:PSwingMouseWheelEvent.java   
/**
 * Calls appropriate method on the listener based on this events ID.
 * 
 * @param listener the target for dispatch.
 */
public void dispatchTo(final Object listener) {
    final MouseWheelListener mouseWheelListener = (MouseWheelListener) listener;
    switch (getID()) {
        case MouseEvent.MOUSE_WHEEL:
            mouseWheelListener.mouseWheelMoved(this);
            break;
        default:
            throw new RuntimeException("PMouseWheelEvent with bad ID");
    }
}