本文整理汇总了Java中java.awt.event.MouseWheelEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java MouseWheelEvent.getSource方法的具体用法?Java MouseWheelEvent.getSource怎么用?Java MouseWheelEvent.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.MouseWheelEvent
的用法示例。
在下文中一共展示了MouseWheelEvent.getSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: issue163946Hack
import java.awt.event.MouseWheelEvent; //导入方法依赖的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: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入方法依赖的package包/类
public void mouseWheelMoved(MouseWheelEvent e) {
// Mouse wheel zooming takes precedence over scrolling
if (isMouseZoomingEnabled() &&
e.getSource() == InteractiveCanvasComponent.this) return;
// Change the ScrollBar value
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int unitsToScroll = e.getUnitsToScroll();
int direction = unitsToScroll < 0 ? -1 : 1;
if (unitsToScroll != 0) {
int increment = scrollBar.getUnitIncrement(direction);
int oldValue = scrollBar.getValue();
int newValue = oldValue + increment * unitsToScroll;
newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
scrollBar.getVisibleAmount()), scrollBar.getMinimum());
if (oldValue != newValue) scrollBar.setValue(newValue);
}
}
}
示例3: mouseWheelMoved
import java.awt.event.MouseWheelEvent; //导入方法依赖的package包/类
@Override
public void mouseWheelMoved(final MouseWheelEvent mwe) {
final JSpinner spinner = (JSpinner) mwe.getSource();
if (mwe.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) {
return;
}
try {
int value = (Integer) spinner.getValue();
int i = 0;
for (i = 0; i < vals.length; i++) {
if (value < vals[i]) {
break;
}
}
if (i >= vals.length) {
i = vals.length - 1;
}
final int mult = mults[i];
value -= mult * mwe.getWheelRotation();
if (value < 0) {
value = 0;
}
spinner.setValue(value);
}
catch (final Exception e) {
DavisUserControlPanel.log.warning(e.toString());
return;
}
}