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