Exemplo n.º 1
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
Exemplo n.º 2
0
  /**
   * Sets a specified <code>Component</code> to be the glass pane for this root pane. The glass pane
   * should normally be a lightweight, transparent component, because it will be made visible when
   * ever the root pane needs to grab input events.
   *
   * <p>The new glass pane's visibility is changed to match that of the current glass pane. An
   * implication of this is that care must be taken when you want to replace the glass pane and make
   * it visible. Either of the following will work:
   *
   * <pre>
   *   root.setGlassPane(newGlassPane);
   *   newGlassPane.setVisible(true);
   * </pre>
   *
   * or:
   *
   * <pre>
   *   root.getGlassPane().setVisible(true);
   *   root.setGlassPane(newGlassPane);
   * </pre>
   *
   * @param glass the <code>Component</code> to use as the glass pane for this <code>JRootPane
   *     </code>
   * @exception NullPointerException if the <code>glass</code> parameter is <code>null</code>
   */
  public void setGlassPane(Component glass) {
    if (glass == null) {
      throw new NullPointerException("glassPane cannot be set to null.");
    }

    AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass, new Rectangle());

    boolean visible = false;
    if (glassPane != null && glassPane.getParent() == this) {
      this.remove(glassPane);
      visible = glassPane.isVisible();
    }

    glass.setVisible(visible);
    glassPane = glass;
    this.add(glassPane, 0);
    if (visible) {
      repaint();
    }
  }
Exemplo n.º 3
0
 /**
  * The <code>glassPane</code> and <code>contentPane</code> have the same bounds, which means
  * <code>JRootPane</code> does not tiles its children and this should return false. On the other
  * hand, the <code>glassPane</code> is normally not visible, and so this can return true if the
  * <code>glassPane</code> isn't visible. Therefore, the return value here depends upon the
  * visibility of the <code>glassPane</code>.
  *
  * @return true if this component's children don't overlap
  */
 public boolean isOptimizedDrawingEnabled() {
   return !glassPane.isVisible();
 }