本文整理汇总了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);
}
示例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();
}
示例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...
}
}
} );
}
示例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);
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}
});
}
示例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;
}
}
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
}