本文整理匯總了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);
}