Java Code Examples for javax.swing.JComponent#removeMouseMotionListener()

The following examples show how to use javax.swing.JComponent#removeMouseMotionListener() . These examples are extracted from open source projects. 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 Project: netbeans   File: ToolTipManagerEx.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * Registers a component for tooltip management.
    * <p>
    * This will register key bindings to show and hide the tooltip text
    * only if <code>component</code> has focus bindings. This is done
    * so that components that are not normally focus traversable, such
    * as <code>JLabel</code>, are not made focus traversable as a result
    * of invoking this method.
    *
    * @param component  a <code>JComponent</code> object to add
    * @see JComponent#isFocusTraversable
    */
   protected void registerComponent(JComponent component) {
       component.removeMouseListener(this);
       component.addMouseListener(this);
       component.removeMouseMotionListener(moveBeforeEnterListener);
component.addMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    // register our accessibility keybindings for this component
    // this will apply globally across L&F
    // Post Tip: Ctrl+F1
    // Unpost Tip: Esc and Ctrl+F1
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
 
Example 2
/**
 * Actually register the rubber as the mouse listener for the provided component.
 *
 * @param component the related component
 */
public final void connectComponent (JComponent component)
{
    // Clean up if needed
    disconnectComponent(this.component);

    // Remember the related component (to get visible rect, etc ...)
    this.component = component;

    if (component != null) {
        // To be notified of mouse clicks
        component.removeMouseListener(this); // No multiple notifications
        component.addMouseListener(this);

        // To be notified of mouse mouvements
        component.removeMouseMotionListener(this); // No multiple notifs
        component.addMouseMotionListener(this);

        // To be notified of mouse  wheel mouvements
        component.removeMouseWheelListener(this); // No multiple notifs
        component.addMouseWheelListener(this);
    }
}
 
Example 3
/**
 * Actually register the rubber as the mouse listener for the provided
 * component.
 *
 * @param component the related component
 */
public void connectComponent (JComponent component)
{
    // Clean up if needed
    disconnectComponent(this.component);

    // Remember the related component (to get visible rect, etc ...)
    this.component = component;

    // To be notified of mouse clicks
    component.removeMouseListener(this); // No multiple notifications
    component.addMouseListener(this);

    // To be notified of mouse mouvements
    component.removeMouseMotionListener(this); // No multiple notifs
    component.addMouseMotionListener(this);

    // To be notified of mouse  wheel mouvements
    component.removeMouseWheelListener(this); // No multiple notifs
    component.addMouseWheelListener(this);
}
 
Example 4
/**
 * 
 * @param event
 */
private void initiateToolTip(MouseEvent event) {

  JComponent component = (JComponent) event.getSource();
  String newToolTipText = component.getToolTipText(event);
  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  component.removeMouseMotionListener(moveBeforeEnterListener);

  Point location = event.getPoint();
  // ensure tooltip shows only in proper place
  if (location.x < 0 || location.x >= component.getWidth() || location.y < 0
      || location.y >= component.getHeight()) {
    return;
  }

  component.removeMouseMotionListener(this);
  component.addMouseMotionListener(this);

  mouseEvent = event;
  toolTipText = newToolTipText;
  preferredLocation = component.getToolTipLocation(event);
  insideComponent = component;

  showTipWindow();
}
 
Example 5
Source Project: netbeans   File: ToolTipManagerEx.java    License: Apache License 2.0 5 votes vote down vote up
/**
    * Removes a component from tooltip control.
    *
    * @param component  a <code>JComponent</code> object to remove
    */
   protected void unregisterComponent(JComponent component) {
       component.removeMouseListener(this);
component.removeMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
 
Example 6
/**
 * Disconnect the provided component
 *
 * @param component the component to disconnect
 */
private void disconnectComponent (JComponent component)
{
    if (component != null) {
        component.removeMouseListener(this);
        component.removeMouseMotionListener(this);
        component.removeMouseWheelListener(this);
    }
}
 
Example 7
Source Project: pumpernickel   File: ColorWellUI.java    License: MIT License 5 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {
	c.removeFocusListener(repaintFocusListener);
	c.removeMouseListener(mouseListener);
	c.removeMouseMotionListener(mouseListener);
	c.removeKeyListener(keyListener);

	JColorWell well = (JColorWell) c;
	ColorChangeListener ccl = listenerMap.remove(well);
	if (ccl != null)
		well.getColorSelectionModel().removeChangeListener(ccl);
}
 
Example 8
Source Project: pumpernickel   File: MultiThumbSliderUI.java    License: MIT License 5 votes vote down vote up
@Override
public void uninstallUI(JComponent slider) {
	slider.removeMouseListener(this);
	slider.removeMouseMotionListener(this);
	slider.removeFocusListener(focusListener);
	slider.removeKeyListener(keyListener);
	slider.removeComponentListener(compListener);
	slider.removePropertyChangeListener(propertyListener);
	slider.removePropertyChangeListener(THUMB_SHAPE_PROPERTY,
			thumbShapeListener);
	super.uninstallUI(slider);
}
 
Example 9
Source Project: pumpernickel   File: NavigationPanelUI.java    License: MIT License 5 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {
	super.uninstallUI(c);
	spinner.removeChangeListener(valueListener);
	UpdateLabelListener changeListener = (UpdateLabelListener) c
			.getClientProperty(PROPERTY_LABEL_CHANGE_LISTENER);
	((JSpinner) c).removeChangeListener(changeListener);
	((JSpinner) c).removePropertyChangeListener(changeListener);
	c.putClientProperty(PROPERTY_LABEL_CHANGE_LISTENER, null);
	c.removeMouseListener(dragListener);
	c.removeMouseMotionListener(dragListener);
}
 
Example 10
/**
 * 
 * @param event
 */
private void initiateToolTip(MouseEvent event) {

  JComponent component = (JComponent) event.getSource();
  String newToolTipText = component.getToolTipText(event);
  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  component.removeMouseMotionListener(moveBeforeEnterListener);

  Point location = event.getPoint();
  // ensure tooltip shows only in proper place
  if (location.x < 0 || location.x >= component.getWidth() || location.y < 0
      || location.y >= component.getHeight()) {
    return;
  }

  component.removeMouseMotionListener(this);
  component.addMouseMotionListener(this);

  mouseEvent = event;
  toolTipText = newToolTipText;
  preferredLocation = component.getToolTipLocation(event);
  insideComponent = component;

  showTipWindow();
}
 
Example 11
@Override
public void uninstallUI(JComponent slider) {
	slider.removeMouseListener(this);
	slider.removeMouseMotionListener(this);
	slider.removeFocusListener(focusListener);
	slider.removeKeyListener(keyListener);
	slider.removeComponentListener(compListener);
	slider.removePropertyChangeListener(propertyListener);
	slider.removePropertyChangeListener(THUMB_SHAPE_PROPERTY, thumbShapeListener);
	super.uninstallUI(slider);
}
 
Example 12
/**
 * Disconnect the provided component
 *
 * @param component the component to disconnect
 */
public void disconnectComponent (JComponent component)
{
    if (component != null) {
        component.removeMouseListener(this);
        component.removeMouseMotionListener(this);
        component.removeMouseWheelListener(this);
    }
}
 
Example 13
Source Project: birt   File: SwingRendererImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Free all allocated system resources.
 */
@Override
public void dispose( )
{
	super.dispose( );
	
	_lhmAllTriggers.clear( );

	if ( _iun != null )
	{
		Object obj = _iun.peerInstance( );

		if ( obj instanceof JComponent )
		{
			JComponent jc = (JComponent) obj;

			if ( _eh != null )
			{
				jc.removeMouseListener( _eh );
				jc.removeMouseMotionListener( _eh );
				jc.removeKeyListener( _eh );
				jc.removeFocusListener( _eh );

				_eh = null;
			}
		}
	}
}
 
Example 14
Source Project: birt   File: SwingRendererImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setProperty( String sProperty, Object oValue )
{
	// InteractiveRenderer(iv) is only for Swing
	if ( sProperty.equals( IDeviceRenderer.UPDATE_NOTIFIER ) && iv != null )
	{
		_iun = (IUpdateNotifier) oValue;
		iv.setUpdateNotifier( _iun );
		_lhmAllTriggers.clear( );
		Object obj = _iun.peerInstance( );

		if ( obj instanceof JComponent )
		{
			JComponent jc = (JComponent) obj;

			if ( _eh != null )
			{
				// We can't promise to remove all the old swtEventHandler
				// due to SWT limitation here, so be sure to just attach the
				// update_notifier only to one renderer.

				jc.removeMouseListener( _eh );
				jc.removeMouseMotionListener( _eh );
				jc.removeKeyListener( _eh );
				jc.removeFocusListener( _eh );
			}

			_eh = new SwingEventHandler( iv,
					_lhmAllTriggers,
					_iun,
					getULocale( ) );
			jc.addMouseListener( _eh );
			jc.addMouseMotionListener( _eh );
			jc.addKeyListener( _eh );
			jc.addFocusListener( _eh );
		}
	}
	
	super.setProperty( sProperty, oValue );
}
 
Example 15
/**
 * Removes a component from tooltip control.
 * 
 * @param component a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
  component.removeMouseListener(this);
  component.removeMouseMotionListener(moveBeforeEnterListener);

}
 
Example 16
Source Project: netbeans   File: ToolTipManagerEx.java    License: Apache License 2.0 4 votes vote down vote up
private void initiateToolTip(MouseEvent event) {
       if (event.getSource() == window) {
           return;
       }
       JComponent component = (JComponent)event.getSource();
component.removeMouseMotionListener(moveBeforeEnterListener);

       exitTimer.stop();

Point location = event.getPoint();
// ensure tooltip shows only in proper place
if (location.x < 0 || 
    location.x >=component.getWidth() ||
    location.y < 0 ||
    location.y >= component.getHeight()) {
    return;
}

       if (insideComponent != null) {
           enterTimer.stop();
       }
// A component in an unactive internal frame is sent two
// mouseEntered events, make sure we don't end up adding
// ourselves an extra time.
       component.removeMouseMotionListener(this);
       component.addMouseMotionListener(this);

       boolean sameComponent = (insideComponent == component);

       insideComponent = component;
if (tipWindow != null){
           mouseEvent = event;
           if (showImmediately) {
               Rectangle rect = provider.getToolTipSourceBounds( event.getPoint() );
               if( null != rect ) {
                   String newToolTipText = startToolTipCalculation( rect, event.getPoint() );

                   if (!sameComponent || !toolTipText.equals(newToolTipText) /*|| 
                            !sameLoc*/) {
                       toolTipText = newToolTipText;
                       showTipWindow();
                   }
               }
           } else {
               enterTimer.start();
           }
       }
   }
 
Example 17
/**
 * Removes a component from tooltip control.
 * 
 * @param component a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
  component.removeMouseListener(this);
  component.removeMouseMotionListener(moveBeforeEnterListener);

}
 
Example 18
Source Project: jfxvnc   File: PointerEventHandler.java    License: Apache License 2.0 4 votes vote down vote up
public void unregister(JComponent node) {
  node.removeMouseMotionListener(mouseMotionEventHandler);
  node.removeMouseListener(mouseEventHandler);
  node.removeMouseWheelListener(mouseWheelEventHandler);
}