当前位置: 首页>>代码示例>>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;未经允许,请勿转载。