public static void installMouseInputAdapterOnAllComponents(MouseInputAdapter m,Container c){
  c.addMouseListener(m);
  c.addMouseMotionListener(m);
  Component[] components=c.getComponents();
  for (int i=0; i < components.length; i++) {
    if (components[i] instanceof Container) {
      MouseInputAdapterInstaller.installMouseInputAdapterOnAllComponents(m,(Container)components[i]);
    }
 else {
      c.addMouseListener(m);
      c.addMouseMotionListener(m);
    }
  }
}

public static void installMouseInputAdapterOnAllComponents ( MouseInputAdapter m , Container c ) { c . addMouseListener ( m ) ; c . addMouseMotionListener ( m ) ; Component [ ] components = c . getComponents ( ) ; for ( int i = 0 ; i < components . length ; i ++ ) { if ( components [ i ] instanceof Container ) { MouseInputAdapterInstaller . installMouseInputAdapterOnAllComponents ( m , ( Container ) components [ i ] ) ; } else { c . addMouseListener ( m ) ; c . addMouseMotionListener ( m ) ; } } }
add a mouseinputadapter to all components .
