Java Swing Mouse addMouseListenerToHierarchy(JComponent c, MouseListener listener)

Here you can find the source of addMouseListenerToHierarchy(JComponent c, MouseListener listener)

Description

add Mouse Listener To Hierarchy

License

Open Source License

Declaration

public static void addMouseListenerToHierarchy(JComponent c, MouseListener listener) 

Method Source Code

//package com.java2s;
/*//from w  w w  .jav  a  2 s  .c  o  m
 * Copyright (c) 2014 tabletoptool.com team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     rptools.com team - initial implementation
 *     tabletoptool.com team - further development
 */

import java.awt.Component;

import java.awt.event.MouseListener;

import javax.swing.JComponent;

public class Main {
    public static void addMouseListenerToHierarchy(JComponent c, MouseListener listener) {
        for (Component comp : c.getComponents()) {
            comp.addMouseListener(listener);

            if (comp instanceof JComponent) {
                addMouseListenerToHierarchy((JComponent) comp, listener);
            }
        }
    }
}

Related

  1. adaptEventToDescendent(MouseEvent e, JComponent descendentTarget)
  2. addMouseListenerToAll(Component parent, MouseListener listener)
  3. animateMouse(Robot robot, JComponent jc, boolean moveMouse, boolean clickOnArrival)
  4. clickedInSelection(MouseEvent e)
  5. convert(MouseEvent event, Component newSource)
  6. convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination)