當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseWheelListener類代碼示例

本文整理匯總了Java中java.awt.event.MouseWheelListener的典型用法代碼示例。如果您正苦於以下問題:Java MouseWheelListener類的具體用法?Java MouseWheelListener怎麽用?Java MouseWheelListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MouseWheelListener類屬於java.awt.event包,在下文中一共展示了MouseWheelListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: issue163946Hack

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:UIUtils.java

示例2: MorphPanel

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
	}
 
開發者ID:ArticulatedSocialAgentsPlatform,項目名稱:HmiCore,代碼行數:25,代碼來源:MorphPanel.java

示例3: MapCanvas

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
/**
 * 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...
			}
		}
	} );
}
 
開發者ID:icza,項目名稱:scelight,代碼行數:27,代碼來源:MapCanvas.java

示例4: initGrammarErrorPane

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
/**
 * 初始化語法錯誤麵板
 */
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);
}
 
開發者ID:Sword-Destiny,項目名稱:CMMParser,代碼行數:21,代碼來源:MainFrame.java

示例5: JScrollPopupMenu

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
        }
    });
}
 
開發者ID:girtel,項目名稱:Net2Plan,代碼行數:22,代碼來源:JScrollPopupMenu.java

示例6: JScrollC2PopupMenu

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
		}
	});
}
 
開發者ID:P15,項目名稱:jailer,代碼行數:20,代碼來源:JScrollC2PopupMenu.java

示例7: JScrollPopupMenu

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
		}
	});
}
 
開發者ID:P15,項目名稱:jailer,代碼行數:20,代碼來源:JScrollPopupMenu.java

示例8: JScrollPopupMenu

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
        }
    });
}
 
開發者ID:friedlwo,項目名稱:AppWoksUtils,代碼行數:17,代碼來源:JScrollPopupMenu.java

示例9: removeMouseWheelListener

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
/**
 * 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;
            }
        }
    }
}
 
開發者ID:josmas,項目名稱:openwonderland,代碼行數:22,代碼來源:Window2D.java

示例10: setModel

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
	}
}
 
開發者ID:RPTools,項目名稱:rplib,代碼行數:24,代碼來源:ImagePanel.java

示例11: getListeners

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
@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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:Component.java

示例12: testProcessMouseWheelEvent

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:ScrollPaneTest.java

示例13: setMouseWheelListener

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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();
                }
            }
        }
    });
}
 
開發者ID:magarena,項目名稱:magarena,代碼行數:18,代碼來源:ImageCardListViewer.java

示例14: registerScrollWheelListener

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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);
			}
		}
	});
}
 
開發者ID:UiL-OTS-labs-backoffice,項目名稱:UiL-OTS-Video-Coding-System,代碼行數:21,代碼來源:ABar.java

示例15: addZoomMouseListeners

import java.awt.event.MouseWheelListener; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:sassoftware,項目名稱:unravl,代碼行數:21,代碼來源:UnRAVLFrame.java


注:本文中的java.awt.event.MouseWheelListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。