Exemplo n.º 1
0
  // installs a private instance of GestureHandler, if necessary
  static void addGestureListenerTo(final JComponent component, final GestureListener listener) {
    final Object value = component.getClientProperty(CLIENT_PROPERTY);
    if (value instanceof GestureHandler) {
      ((GestureHandler) value).addListener(listener);
      return;
    }

    if (value != null) return; // some other garbage is in our client property

    final GestureHandler newHandler = new GestureHandler();
    newHandler.addListener(listener);
    component.putClientProperty(CLIENT_PROPERTY, newHandler);
  }
Exemplo n.º 2
0
 // asks the installed GestureHandler to remove it's listener (does not uninstall the
 // GestureHandler)
 static void removeGestureListenerFrom(
     final JComponent component, final GestureListener listener) {
   final Object value = component.getClientProperty(CLIENT_PROPERTY);
   if (!(value instanceof GestureHandler)) return;
   ((GestureHandler) value).removeListener(listener);
 }