/**
  * @param title the title to be displayed in this tab
  * @param icon the icon to be displayed in this tab
  * @param component The component to be displayed when this tab is clicked.
  * @param tip the tooltip to be displayed for this tab
  * @param index the position to insert this new tab
  * @see javax.swing.JTabbedPane#insertTab(java.lang.String, javax.swing.Icon, java.awt.Component,
  *     java.lang.String, int)
  */
 @Override
 public void insertTab(String title, Icon icon, Component component, String tip, int index) {
   super.insertTab(title, icon, component, tip, index);
   try {
     Method method =
         this.getClass().getMethod("setTabComponentAt", new Class[] {int.class, Component.class});
     method.invoke(this, index, new CloseTabComponent(title, this));
     component.addKeyListener(this);
     /*if (component instanceof Container) {
       Container container = (Container) component;
       for (Component child : container.getComponents()) {
         child.addKeyListener(this);
       }
     }*/
   } catch (SecurityException e) {
     // Nothing
   } catch (NoSuchMethodException e) {
     // Nothing
   } catch (IllegalArgumentException e) {
     // Nothing
   } catch (IllegalAccessException e) {
     // Nothing
   } catch (InvocationTargetException e) {
     // Nothing
   }
   setIconAt(index, new JTabbedPaneCloseIcon(this, component));
 }
Esempio n. 2
0
  /**
   * Arena consturctor.
   *
   * @param parent The component where the arena will be displayed in.
   */
  public Arena(Component parent) {
    super();
    this.parent = parent;
    this.isVisible = false;
    if (parent == null) {
      this.isVisible = false;
    } else {
      parent.addKeyListener(this);
    }

    FrictionBuffer get = frictionBufferCache.get(this.svgFileName);
    if (get == null) { // if not in cache, create new instance and
      frictionBuffer = new FrictionBuffer(this);
      frictionBufferCache.put(this.svgFileName, frictionBuffer);
      if (DEBUG_FRICTION_CACHE) {
        System.out.println(
            "Cached friction buffer not found, I have created new instance and cached it.");
      }
    } else {
      frictionBuffer = get;
      if (DEBUG_FRICTION_CACHE) {
        System.out.println("Cached friction buffer found.");
      }
    }
  }
Esempio n. 3
0
  private void formWindowOpened(
      java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowOpened
    lst = new ListRsbm();
    lst2 = new ListRsbmNota();

    lst.setVisible(false);
    lst.setSize(500, 200);
    lst.con = conn;

    lst2.setVisible(false);
    lst2.setSize(500, 200);
    lst2.con = conn;

    MyKeyListener kListener = new MyKeyListener();
    for (int i = 0; i < jPanel1.getComponentCount(); i++) {
      Component c = jPanel1.getComponent(i);
      if (c.getClass().getSimpleName().equalsIgnoreCase("JTEXTFIELD")
          || c.getClass().getSimpleName().equalsIgnoreCase("JFormattedTextField")
          || c.getClass().getSimpleName().equalsIgnoreCase("JTextArea")
          || c.getClass().getSimpleName().equalsIgnoreCase("JComboBox")
          || c.getClass().getSimpleName().equalsIgnoreCase("JButton")
          || c.getClass().getSimpleName().equalsIgnoreCase("JCheckBox")
          || c.getClass().getSimpleName().equalsIgnoreCase("JRadioButton")) {
        // System.out.println(c.getClass().getSimpleName());
        c.addKeyListener(kListener);
      }
    }
  } // GEN-LAST:event_formWindowOpened
Esempio n. 4
0
 /**
  * Registers a controller to an Active object. If the controller extends KeyboardVivaeController
  * it also registers it to the parent component as a new KeyListener.
  *
  * @param agent The Active the controller will control.
  * @param controller The controller specifing behavior of the Active object.
  */
 public void registerController(Active agent, VivaeController controller) {
   controller.setControlledObject(agent);
   controllers.add(controller);
   if (agent instanceof Robot && controller instanceof KeyboardVivaeController) {
     if (parent != null) parent.addKeyListener((KeyboardVivaeController) controller);
     this.addKeyListener((KeyboardVivaeController) controller);
   }
 }
Esempio n. 5
0
 public void setParent(Component parent) {
   this.parent = parent;
   this.isVisible = false;
   if (parent == null) {
     this.isVisible = false;
   } else {
     parent.addKeyListener(this);
   }
 }
Esempio n. 6
0
 private void componentAdded(Component comp) {
   comp.addKeyListener(keyHandler);
   if (comp instanceof Container) {
     Container cont = (Container) comp;
     cont.addContainerListener(this);
     Component[] comps = cont.getComponents();
     for (Component comp1 : comps) componentAdded(comp1);
   }
 }
 /** Recursively listens for keyboard events on the given component. */
 private void addKeyDispatcher(final AWTInputEventDispatcher dispatcher, final Component comp) {
   comp.addKeyListener(dispatcher);
   if (!(comp instanceof Container)) return;
   final Container c = (Container) comp;
   final int childCount = c.getComponentCount();
   for (int i = 0; i < childCount; i++) {
     final Component child = c.getComponent(i);
     addKeyDispatcher(dispatcher, child);
   }
 }
Esempio n. 8
0
 public InputManager(Component component) {
   this.component = component;
   mouseLocation = new Point();
   centerLocation = new Point();
   component.addKeyListener(this);
   component.addMouseListener(this);
   component.addMouseMotionListener(this);
   component.addMouseWheelListener(this);
   component.setFocusTraversalKeysEnabled(false);
 }
Esempio n. 9
0
 /**
  * Registers a controller to an Active object. If the controller extends KeyboardVivaeController
  * it also registers it to the parent component as a new KeyListener.
  *
  * @param agent The Active the controller will control.
  * @param controller The controller specifing behavior of the Active object.
  */
 public void registerController(IRobotInterface agent, VivaeController controller) {
   controller.setControlledObject(agent);
   controllers.add(controller);
   if (agent instanceof VivaeRobotRepresent && controller instanceof KeyboardVivaeController) {
     if (parent != null) {
       parent.addKeyListener((KeyboardVivaeController) controller);
     }
     this.addKeyListener((KeyboardVivaeController) controller);
   }
 }
Esempio n. 10
0
  /**
   * Adds default interactions to the specified component.
   *
   * @param comp component
   * @param win parent window
   */
  public static void addInteraction(final Component comp, final Window win) {
    comp.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            focus(comp);
          }
        });

    if (win instanceof BaseXDialog) {
      // add default keys
      final BaseXDialog d = (BaseXDialog) win;
      comp.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyPressed(final KeyEvent e) {
              final Object s = e.getSource();
              if (s instanceof BaseXCombo && ((BaseXCombo) s).isPopupVisible()) return;

              // do not key close dialog if button or editor is focused
              if (ENTER.is(e) && !(s instanceof BaseXButton || s instanceof TextPanel)) {
                d.close();
              } else if (ESCAPE.is(e)) {
                // do not cancel dialog if search bar is opened
                boolean close = true;
                if (s instanceof TextPanel) {
                  final SearchBar bar = ((TextPanel) s).getSearch();
                  close = bar == null || !bar.deactivate(true);
                }
                if (close) d.cancel();
              }
            }
          });
      return;
    }

    if (win instanceof GUI) {
      comp.addKeyListener(globalShortcuts((GUI) win));
    } else {
      throw Util.notExpected("Reference to main window expected.");
    }
  }
Esempio n. 11
0
 /** @param c */
 private void addKeyAndContainerListenerRecursively(Component c) {
   c.removeKeyListener(keyListener);
   c.addKeyListener(keyListener);
   if (c instanceof Container) {
     Container cont = (Container) c;
     Component[] children = cont.getComponents();
     for (int i = 0; i < children.length; i++) {
       addKeyAndContainerListenerRecursively(children[i]);
     }
   }
 }
Esempio n. 12
0
  /**
   * Arena consturctor.
   *
   * @param parent The component where the arena will be displayed in.
   */
  public Arena(Component parent) {

    super();
    this.parent = parent;
    this.isVisible = false;
    if (parent == null) {
      this.isVisible = false;
    } else {
      parent.addKeyListener(this);
    }
  }
Esempio n. 13
0
 /**
  * This method adds a {@link KeyListener} to all added components. This is done recursively.
  *
  * @param c The {@link Component} that is added.
  */
 private void addKeyAndContainerListenerRecursively(final Component c) {
   c.addKeyListener(this);
   if (c instanceof Container) {
     final Container cont = (Container) c;
     cont.addContainerListener(this);
     final Component[] children = cont.getComponents();
     for (int i = 0; i < children.length; i++) {
       addKeyAndContainerListenerRecursively(children[i]);
     }
   }
 }
Esempio n. 14
0
  public InputManager(Component comp) {
    this.comp = comp;
    mousePosition = new Point();
    centerLocation = new Point();

    // register Listeners
    comp.addKeyListener(this);
    comp.addMouseListener(this);
    comp.addMouseMotionListener(this);
    comp.addMouseWheelListener(this);

    // tell focus traversal to take a hike!
    comp.setFocusTraversalKeysEnabled(false);
  }
Esempio n. 15
0
 void installListeners(Component component) {
   for (ComponentListener listener : componentListeners) component.addComponentListener(listener);
   for (KeyListener listener : keyListeners) component.addKeyListener(listener);
   for (MouseListener listener : mouseListeners) component.addMouseListener(listener);
   for (MouseMotionListener listener : mouseMotionListeners)
     component.addMouseMotionListener(listener);
   if (component instanceof Container) {
     Container container = (Container) component;
     container.addContainerListener(containerListener);
     for (int iComp = container.getComponentCount(); iComp-- != 0; ) {
       installListeners(container.getComponent(iComp));
     }
   }
 }
Esempio n. 16
0
  /** Creates a new InputManager that listens to input from the specified component. */
  public InputManager(Component comp) {
    this.comp = comp;
    mouseLocation = new Point();
    centerLocation = new Point();

    // register key and mouse listeners
    comp.addKeyListener(this);
    comp.addMouseListener(this);
    comp.addMouseMotionListener(this);
    comp.addMouseWheelListener(this);

    // allow input of the TAB key and other keys normally
    // used for focus traversal
    comp.setFocusTraversalKeysEnabled(false);
  }
 // METODOS KEYLISTENER
 // KEYLISTENER RECURSIVO (COLOCA EM TODOS OS COMPONENTES)
 private void addKeyAndContainerListenerRecursively(Component c) {
   try {
     c.addKeyListener(this);
     if (c instanceof Container) {
       Container cont = (Container) c;
       cont.addContainerListener(this);
       Component[] children = cont.getComponents();
       for (int i = 0; i < children.length; i++) {
         addKeyAndContainerListenerRecursively(children[i]);
       }
     }
   } catch (Exception e) {
     // Anuncie Aqui
   }
 }
Esempio n. 18
0
        private void windowOpened0(final IInfoQueryCriteria parameter) {
          final I_AD_InfoColumn infoColumn = parameter.getAD_InfoColumn();
          if (infoColumn == null) {
            return; // shall not happen...
          }

          final String defaultValue = infoColumn.getDefaultValue();

          // search for first not null component
          for (int i = 0; i < parameter.getParameterCount(); i++) {
            final Component editor = getEditorComponentOrNull(parameter, i);
            if (editor == null) {
              continue;
            }

            // add general listeners on parameter components
            editor.addKeyListener(
                new KeyAdapter() {
                  @Override
                  public void keyReleased(final KeyEvent e) {
                    if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                      // each field shall execute query on enter
                      executeQuery();
                    }
                  }
                });

            // we are focusing on field which as "SearchText" as default value
            if (defaultValue == null || defaultValue.indexOf(ATTR_SearchText) < 0) {
              return;
            }

            editor.requestFocus();

            final String text = parameter.getText();
            if (!Check.isEmpty(text, true)) {
              executeQueryOnInit();
            }
          }
        }
  /**
   * Constructor.
   *
   * @param eventSource source of the mouse and key events which will be translated into scripting
   *     language commands. Such a typical source is e.g. the VNC viewer panel.
   */
  public RecordingModule(
      MainFrame frame, Component eventSource, ScriptManager scriptManager, UserConfiguration cfg) {
    this.cfg = cfg;
    this.scriptManager = scriptManager;
    readOnly = cfg.getBoolean("rfb.readOnly").booleanValue();

    fb = (DesktopViewer) eventSource;
    fb.removeMouseListener(fb);
    eventSource.addMouseListener(this);
    fb.addMouseListener(fb);
    eventSource.addMouseMotionListener(this);
    eventSource.addMouseWheelListener(this);
    eventSource.addKeyListener(this);

    client = scriptManager.getClient();
    if (client != null) {
      client.addServerListener(this);
    }

    //        scriptManager.addMouseInputListener(this);
    //        scriptManager.addKeyListener(this);

    // Number of archived events
    //        events.setSize(EVENT_VECTOR_SIZE);

    // Populate the reversed keycode->keyname Map
    Map t = Utils.getKeyCodeTable();
    Iterator e = t.keySet().iterator();
    Object o;
    while (e.hasNext()) {
      o = e.next();
      keyCodes.put(t.get(o), o);
    }
    cfg.addConfigurationListener(this);
    scriptManager.addScriptListener(this);
    configurationChanged(null);
  }
Esempio n. 20
0
 public static void registerKeyboard(Component c) {
   c.addKeyListener(getSingleton());
 }
Esempio n. 21
0
 /** Starts listening for key events from the specified Component. */
 public void attach(Component to) {
   // logger.debug("KeyEventManager attaching.");
   to.addKeyListener(myListener);
 }