Java Code Examples for java.awt.Component#removeMouseListener()

The following examples show how to use java.awt.Component#removeMouseListener() . 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
/**
 * Adds an action to the menu
 * @deprecated Use add(imageURL) instead
 * @param action The action to add
 * @param width The width
 * @param height The height
 * @return The created component
 */
@Deprecated
public Component add(Action action, int width, int height){
    URL url = (URL) action.getValue(AbstractCarouselMenuAction.ACTION_IMAGE_URL);
    if (url==null){
        throw new InvalidParameterException("Supplied action does not have Image URL key (AbstractCarouselMenuAction.ACTION_IMAGE_URL)"
                );
    }
    Component comp = carousel.add(url.toString());
    MenuItem item = new MenuItem(comp, (String) action.getValue(Action.SHORT_DESCRIPTION), action);
    menuItems.addLast(item);
    menuMap.put(comp, item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    return comp;        
}
 
Example 2
Source Project: pumpernickel   File: SplayedLayout.java    License: MIT License 6 votes vote down vote up
private void process(MouseEvent e) {
	Component c = e.getComponent();
	JComponent splayedAncestor = (JComponent) getSplayedAncestor(c);
	if (splayedAncestor == null) {
		c.removeMouseListener(this);
	} else if (prioritizeRollover) {
		if (e.getID() == MouseEvent.MOUSE_ENTERED
				&& splayedAncestor
						.getClientProperty(PROPERTY_ROLLOVER_CHILD) != c) {
			splayedAncestor.putClientProperty(PROPERTY_ROLLOVER_CHILD,
					c);
			splayedAncestor.revalidate();
		} else if (e.getID() == MouseEvent.MOUSE_EXITED
				&& splayedAncestor
						.getClientProperty(PROPERTY_ROLLOVER_CHILD) == c) {
			splayedAncestor.putClientProperty(PROPERTY_ROLLOVER_CHILD,
					null);
			splayedAncestor.revalidate();
		}
	}
}
 
Example 3
Source Project: pdfxtk   File: ContextMenuManager.java    License: Apache License 2.0 6 votes vote down vote up
private void setupML(Component cmp, boolean add) {
   if(cmp instanceof Container) { 
     Component[] cmps = ((Container)cmp).getComponents();
     for(int i = 0; i < cmps.length; i++)
if(cmps[i] instanceof Component) 
  setupML(cmps[i], add);
     
   } else if(cmp instanceof JScrollPane) {
     if(((JScrollPane)cmp).getViewport().getView() instanceof Component)
setupML(((JScrollPane)cmp).getViewport().getView(), add);
     return;
   }
   if(add)
     cmp.addMouseListener(this);
   else
     cmp.removeMouseListener(this);
 }
 
Example 4
/**
 * Adds a component to the carousel menu that will be brought into view when the user clicks
 * on the associated item
 * @param component The component
 * @param label The text to appear in the menu
 * @return The created component
 */
public Component add(Component component,String label){
    carousel.add(label,component);
    MenuItem item = new MenuItem(component, label, null);
    menuItems.addLast(item);
    menuModel.addElement(item);
    menuMap.put(component, item);
    component.removeMouseListener(carousel);
    return component;
}
 
Example 5
/**
 * Adds an image to the menu.
 * @deprecated Use add(Image, String) instead
 * @param image The image
 * @param label The text
 * @param width Prefered width
 * @param height Prefered height
 * @return The created component
 */
@Deprecated
public Component add(Image image, String label, int width, int height) {
    Component comp = carousel.add(image, null);
    MenuItem item = new MenuItem(comp, label, null);
    menuItems.addLast(item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    menuMap.put(comp, item);
    return comp;
}
 
Example 6
/**
 * Adds an image (with a label) and returns the component created to represent them
 * @param image The image to display
 * @param label The label to show
 * @return The component created
 */
public Component add(Image image, String label) {
    Component comp = carousel.add(image, null);
    MenuItem item = new MenuItem(comp, label, null);
    menuItems.addLast(item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    menuMap.put(comp, item);
    return comp;
}
 
Example 7
/**
 * Adds an action to the list, creating a menu item and a carousel entry
 * @param action The action to add
 * @return The resultant component
 */
public Component add(Action action){
    URL url = (URL) action.getValue(AbstractCarouselMenuAction.ACTION_IMAGE_URL);
    if (url==null){
        throw new InvalidParameterException("Supplied action does not have Image URL key (AbstractCarouselMenuAction.ACTION_IMAGE_URL)"
                );
    }
    Component comp = carousel.add(url.toString());
    MenuItem item = new MenuItem(comp, (String) action.getValue(Action.SHORT_DESCRIPTION), action);
    menuItems.addLast(item);
    menuMap.put(comp, item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    return comp;        
}
 
Example 8
/**
 * Adds an image (through a URL) to the menu
 * @deprecated Use add(imageURL, label) instead
 * @param imageURL URL of the image
 * @param label Text message
 * @param width width
 * @param height height
 * @return The created component
 */
@Deprecated
public Component add(String imageURL, String label, int width, int height){
    Component comp = carousel.add(imageURL);
    MenuItem item = new MenuItem(comp, label, null);
    menuMap.put(comp, item);
    menuItems.addLast(item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    return comp;
}
 
Example 9
/**
 * Adds an image based on the imageURL and a text label, returning the component that is created as a result
 * @param imageURL The URL of the image
 * @param label Text label to be shown in the menu
 * @return The created component
 */
public Component add(String imageURL, String label){
    Component comp = carousel.add(imageURL);
    MenuItem item = new MenuItem(comp, label, null);
    menuMap.put(comp, item);
    menuItems.addLast(item);
    menuModel.addElement(item);
    comp.removeMouseListener(carousel);
    return comp;
}
 
Example 10
public void removeItem(Component c) {
    if (toolbar != null) {
        toolbar.remove(c);
    } else {
        if (c instanceof AbstractButton) {
            c.removeMouseListener(listener);
            ((AbstractButton) c).removeChangeListener(listener);
            c.removeFocusListener(listener);
        }
        remove(c);
    }
    repaint();
}
 
Example 11
Source Project: pumpernickel   File: MagnificationPanel.java    License: MIT License 5 votes vote down vote up
private void removeMouseListeners(Component c) {
	c.removeMouseMotionListener(mouseListener);
	c.removeMouseListener(mouseListener);
	if (c instanceof Container) {
		Container c2 = (Container) c;
		c2.removeContainerListener(containerListener);
		for (Component child : c2.getComponents()) {
			addMouseListeners(child);
		}
	}
}
 
Example 12
Source Project: pumpernickel   File: DescendantMouseListener.java    License: MIT License 5 votes vote down vote up
/**
 * Remove all our internal listeners from a component and its descendants.
 */
private void removeListeners(DefaultMutableTreeNode componentNode) {
	Component c = (Component) componentNode.getUserObject();
	c.removeHierarchyListener(hierarchyListener);
	c.removeMouseListener(mouseListener);
	c.removeMouseMotionListener(mouseListener);
	for (int a = 0; a < componentNode.getChildCount(); a++) {
		removeListeners((DefaultMutableTreeNode) componentNode
				.getChildAt(a));
	}
	if (c instanceof Container)
		((Container) c).removeContainerListener(containerListener);
}
 
Example 13
private void removeListeners(Component com) {
    com.removeMouseListener(ma);
    com.removeMouseMotionListener(mma);

}
 
Example 14
/**
 *  Remove listeners from the specified component
 *
 *  @param component  the component the listeners are removed from
 */
public void deregisterComponent(Component... components)
{
	for (Component component : components)
		component.removeMouseListener( this );
}
 
Example 15
public void detachFromComponent(Component c) {
    c.removeMouseListener(this);
    c.removeMouseMotionListener(this);
}
 
Example 16
public void detach(Component cmp) {
  if (cmp != null) {
    cmp.removeMouseListener(this);
    cmp.removeMouseMotionListener(this);
  }
}
 
Example 17
Source Project: SikuliX1   File: ComponentMover.java    License: MIT License 3 votes vote down vote up
/**

    *  Remove listeners from the specified component

    *

    *  @param components  components the listeners are removed from

    */

   public void deregisterComponent(Component... components)

   {

      for (Component component : components)

         component.removeMouseListener( this );

   }