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

The following examples show how to use java.awt.Component#removeMouseListener() . 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: ContextMenuManager.java    From pdfxtk with 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 2
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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 3
Source File: SplayedLayout.java    From pumpernickel with 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 4
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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
Source File: DescendantMouseListener.java    From pumpernickel with 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 6
Source File: MagnificationPanel.java    From pumpernickel with 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 7
Source File: TransparentToolBar.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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 8
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 9
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 10
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 11
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 12
Source File: JCarouselMenu.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 13
Source File: WindowMover.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 4 votes vote down vote up
private void removeListeners(Component com) {
    com.removeMouseListener(ma);
    com.removeMouseMotionListener(mma);

}
 
Example 14
Source File: ComponentMover.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 *  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
Source File: DragReorderHandler.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public void detachFromComponent(Component c) {
    c.removeMouseListener(this);
    c.removeMouseMotionListener(this);
}
 
Example 16
Source File: GlobalMouseAdapter.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
public void detach(Component cmp) {
  if (cmp != null) {
    cmp.removeMouseListener(this);
    cmp.removeMouseMotionListener(this);
  }
}
 
Example 17
Source File: ComponentMover.java    From SikuliX1 with 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 );

   }