コード例 #1
1
 public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
コード例 #2
0
  /**
   * Invoked when a property changes. <code>MetalRootPaneUI</code> is primarily interested in events
   * originating from the <code>JRootPane</code> it has been installed on identifying the property
   * <code>windowDecorationStyle</code>. If the <code>windowDecorationStyle</code> has changed to a
   * value other than <code>JRootPane.NONE</code>, this will add a <code>Component</code> to the
   * <code>JRootPane</code> to render the window decorations, as well as installing a <code>Border
   * </code> on the <code>JRootPane</code>. On the other hand, if the <code>windowDecorationStyle
   * </code> has changed to <code>JRootPane.NONE</code>, this will remove the <code>Component</code>
   * that has been added to the <code>JRootPane</code> as well resetting the Border to what it was
   * before <code>installUI</code> was invoked.
   *
   * @param e A PropertyChangeEvent object describing the event source and the property that has
   *     changed.
   */
  public void propertyChange(PropertyChangeEvent e) {
    super.propertyChange(e);

    String propertyName = e.getPropertyName();
    if (propertyName == null) {
      return;
    }

    if (propertyName.equals("windowDecorationStyle")) {
      JRootPane root = (JRootPane) e.getSource();
      int style = root.getWindowDecorationStyle();

      // This is potentially more than needs to be done,
      // but it rarely happens and makes the install/uninstall process
      // simpler. MetalTitlePane also assumes it will be recreated if
      // the decoration style changes.
      uninstallClientDecorations(root);
      if (style != JRootPane.NONE) {
        installClientDecorations(root);
      }
    } else if (propertyName.equals("ancestor")) {
      uninstallWindowListeners(root);
      if (((JRootPane) e.getSource()).getWindowDecorationStyle() != JRootPane.NONE) {
        installWindowListeners(root, root.getParent());
      }
    }
    return;
  }
コード例 #3
0
 public boolean isResizable(Component c) {
   boolean resizable = true;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     resizable = dialog.isResizable();
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     resizable = frame.isResizable();
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       resizable = frame.isResizable();
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       resizable = dialog.isResizable();
     }
   }
   return resizable;
 }
コード例 #4
0
  /**
   * Installs the necessary state onto the JRootPane to render client decorations. This is ONLY
   * invoked if the <code>JRootPane</code> has a decoration style other than <code>JRootPane.NONE
   * </code>.
   */
  private void installClientDecorations(JRootPane root) {
    installBorder(root);

    JComponent titlePane = createTitlePane(root);

    setTitlePane(root, titlePane);
    installWindowListeners(root, root.getParent());
    installLayout(root);
    if (window != null) {
      root.revalidate();
      root.repaint();
    }
  }
コード例 #5
0
  public void cancel(InputEvent e) {
    if (isDisposed()) return;

    if (myPopup != null) {
      if (!canClose()) {
        return;
      }
      storeDimensionSize(myContent.getSize());
      if (myUseDimServiceForXYLocation) {
        final JRootPane root = myComponent.getRootPane();
        if (root != null) {
          final Container popupWindow = root.getParent();
          if (popupWindow != null && popupWindow.isShowing()) {
            storeLocation(popupWindow.getLocationOnScreen());
          }
        }
      }

      if (e instanceof MouseEvent) {
        IdeEventQueue.getInstance().blockNextEvents(((MouseEvent) e));
      }

      myPopup.hide(false);

      if (ApplicationManagerEx.getApplicationEx() != null) {
        StackingPopupDispatcher.getInstance().onPopupHidden(this);
      }

      if (myInStack) {
        myFocusTrackback.setForcedRestore(!myOk && myFocusable);
        myFocusTrackback.restoreFocus();
      }

      disposePopup();

      if (myListeners != null) {
        for (JBPopupListener each : myListeners) {
          each.onClosed(new LightweightWindowEvent(this, myOk));
        }
      }
    }

    Disposer.dispose(this, false);
  }