Esempio n. 1
0
  /**
   * Method description
   *
   * @param window
   */
  public static void centerWindow(Window window) {

    Dimension dimension = window.getSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screenSize.width - dimension.width) / 2;
    int y = (screenSize.height - dimension.height) / 2;
    window.setLocation(x, y);
    window.requestFocus();
  }
Esempio n. 2
0
  public void setVisible(boolean b) {
    KeyboardFocusManager keyboardFocusManager =
        KeyboardFocusManager.getCurrentKeyboardFocusManager();
    if (b) {
      keyboardFocusManager.addKeyEventDispatcher(keyManager);
    } else {
      keyboardFocusManager.removeKeyEventDispatcher(keyManager);
    }
    super.setVisible(b);

    Window owner = getOwner();
    if (owner != null) {
      owner.requestFocus();
      if (lastFocusOwner != null) {
        lastFocusOwner.requestFocusInWindow();
      }
    }
  }
Esempio n. 3
0
  /**
   * Mark this panel as focused. When gaining focus the panel will automatically request focus for
   * its parent frame.
   *
   * @remark The focus system implemented here has nothing to do with swings focus system, therefore
   *     Swings focus methods won't work.
   * @param hasFocus has the focus
   */
  protected void setFocus(boolean hasFocus) {

    // don't change anything if it's not necessary
    if (this.hasFocus == hasFocus) return;

    this.hasFocus = hasFocus;

    if (hasFocus) {
      // request focus and change toolbar if necessary
      if (openInFrame) {
        frame.requestFocus();
      } else {
        if (!app.isApplet()) {
          JFrame frame = app.getFrame();

          if (frame != null) {
            frame.toFront();
          }
        }

        setActiveToolBar();
      }
    } else {

    }

    // call callback methods for focus changes
    if (hasFocus) {
      focusGained();
    } else {
      focusLost();
    }

    /*
     * Mark the focused view in bold if the focus system is available. If
     * this isn't the case we always stick with the normal font as it would
     * confuse the users that the focus "indicator" just changes if we
     * switch between EVs.
     */
    setTitleLabelFocus();
  }