Java Code Examples for java.awt.Container#dispatchEvent()

The following examples show how to use java.awt.Container#dispatchEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From javamelody with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
	// on reporte l'évènement mouseWheelMoved de ce scrollPane vers son parent
	final Container parent = event.getComponent().getParent();
	parent.dispatchEvent(
			SwingUtilities.convertMouseEvent(event.getComponent(), event, parent));
}
 
Example 2
Source File: ProcessPanelScroller.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void mouseWheelMoved(final MouseWheelEvent e) {
	if (e.isControlDown() && e.getWheelRotation() != 0) {
		double oldZoomFactor = rendererView.getModel().getZoomFactor();
		if (e.getWheelRotation() < 0) {
			rendererView.getModel().zoomIn();
		} else {
			rendererView.getModel().zoomOut();
		}
		rendererView.getModel().fireProcessZoomChanged();

		// calculate how the scrollbar needs to be adjusted for centered zoom
		double relativeZoomFactor = rendererView.getModel().getZoomFactor() / oldZoomFactor;
		double differenceHorizontal = e.getPoint().getX() * (relativeZoomFactor - 1);
		double differenceVertical = e.getPoint().getY() * (relativeZoomFactor - 1);

		int newX = Math.max(0, (int) (scrollPane.getHorizontalScrollBar().getValue() + differenceHorizontal));
		int newY = Math.max(0, (int) (scrollPane.getVerticalScrollBar().getValue() + differenceVertical));

		scrollPane.getHorizontalScrollBar().setValue(newX);
		scrollPane.getVerticalScrollBar().setValue(newY);

		// prevent flickering when another adjustment of the scrollbars is needed
		RepaintManager.currentManager(scrollPane).markCompletelyClean(scrollPane);

		/**
		 * Setting the value as above does not always work since the scrollbars are not yet
		 * updated to the size changes caused by the zooming. Set flag an values to try
		 * again after the resizing happened.
		 */
		zoomed = true;
		desiredVerticalScrollValue = newY;
		desiredHorizontalScrollValue = newX;
		return;
	}

	Container p = rendererView.getParent();
	if (p != null) {
		p.dispatchEvent(SwingUtilities.convertMouseEvent(rendererView, e, p));
	}
}
 
Example 3
Source File: MindMapPanel.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
private void sendToParent(@Nonnull final AWTEvent evt) {
  final Container parent = this.getParent();
  if (parent != null) {
    parent.dispatchEvent(evt);
  }
}
 
Example 4
Source File: ScalableImage.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
private void sendEventToParent(@Nonnull final MouseEvent e) {
  final Container parent = this.getParent();
  if (parent != null) {
    parent.dispatchEvent(e);
  }
}