本文整理汇总了Java中java.awt.event.MouseWheelListener.mouseWheelMoved方法的典型用法代码示例。如果您正苦于以下问题:Java MouseWheelListener.mouseWheelMoved方法的具体用法?Java MouseWheelListener.mouseWheelMoved怎么用?Java MouseWheelListener.mouseWheelMoved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.MouseWheelListener
的用法示例。
在下文中一共展示了MouseWheelListener.mouseWheelMoved方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseWheelMoved
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
@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);
}
示例2: mouseWheelMoved
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
/**
* 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();
}
}
}
示例3: dispatchTo
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
/**
* 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");
}
}
示例4: deliverEvent
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
/**
* Deliver the given mouse wheel event to the window.
*
* @param event The mouse wheel event to deliver.
*/
protected void deliverEvent(MouseWheelEvent event) {
if (mouseWheelListeners == null) {
return;
}
for (MouseWheelListener listener : mouseWheelListeners) {
listener.mouseWheelMoved(event);
}
}
示例5: mouseWheelMoved
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent evt) {
if(!canDispatch(evt)) {return;}
MouseWheelEvent e = new MouseWheelEvent(evt.getComponent(), evt.getID(), evt.getWhen(), evt.getModifiers(), evt.getX(), evt.getY(), evt.getClickCount(), false, evt.getScrollType(), evt.getScrollAmount(), evt.getWheelRotation());
MouseWheelListener[] listeners = getListenersAndAdaptEvent(e, MouseWheelListener.class);
for(MouseWheelListener l : listeners) {l.mouseWheelMoved(e);}
}
示例6: processMouseWheelEventImpl
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
private void processMouseWheelEventImpl(MouseWheelEvent e, Collection<MouseWheelListener> c) {
for (MouseWheelListener listener : c) {
switch (e.getID()) {
case MouseEvent.MOUSE_WHEEL:
listener.mouseWheelMoved(e);
break;
}
}
}
示例7: fireMouseWheelEvent
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
private void fireMouseWheelEvent(MouseWheelEvent e) {
for (MouseWheelListener l : mMouseWheelListeners) {
if (e.getID() == MouseEvent.MOUSE_WHEEL) {
l.mouseWheelMoved(e);
}
}
}
示例8: callMouseWheelMovedListeners
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
protected void callMouseWheelMovedListeners(MouseWheelEvent event)
{
for (MouseWheelListener listener : this.eventListeners.getListeners(MouseWheelListener.class))
{
listener.mouseWheelMoved(event);
}
}
示例9: setUI
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
@Override
public void setUI(ScrollPaneUI ui) {
super.setUI(ui);
updateViewportBorder();
if (ui instanceof BasicScrollPaneUI) {
try {
Field field = BasicScrollPaneUI.class.getDeclaredField("mouseScrollListener");
field.setAccessible(true);
Object value = field.get(ui);
if (value instanceof MouseWheelListener) {
MouseWheelListener oldListener = (MouseWheelListener)value;
MouseWheelListener newListener = event -> {
if (isScrollEvent(event)) {
Object source = event.getSource();
if (source instanceof JScrollPane) {
JScrollPane pane = (JScrollPane)source;
if (pane.isWheelScrollingEnabled()) {
JScrollBar bar = event.isShiftDown() ? pane.getHorizontalScrollBar() : pane.getVerticalScrollBar();
if (bar != null && bar.isVisible()) oldListener.mouseWheelMoved(event);
}
}
}
};
field.set(ui, newListener);
// replace listener if field updated successfully
removeMouseWheelListener(oldListener);
addMouseWheelListener(newListener);
}
}
catch (Exception exception) {
LOG.warn(exception);
}
}
}
示例10: fireMouseWheelEvent
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
private void fireMouseWheelEvent(MouseWheelEvent e)
{
for (MouseWheelListener l : mMouseWheelListeners)
if (e.getID() == MouseEvent.MOUSE_WHEEL)
l.mouseWheelMoved(e);
}
示例11: mouseWheelMoved
import java.awt.event.MouseWheelListener; //导入方法依赖的package包/类
public void mouseWheelMoved(MouseWheelEvent e) {
MouseWheelListener[] listeners = getListenerAncestor(e, MouseWheelListener.class);
if(listeners!=null) for(MouseWheelListener l : listeners) l.mouseWheelMoved(e);
}