private void hideDropDownButton() {
   for (Component component : this.getComponents()) {
     if (component instanceof AbstractButton && component.isVisible()) {
       component.setVisible(false);
       this.revalidate();
     }
   }
 }
    public void layoutContainer(Container parent) {
      Dimension size = parent.getSize();

      Dimension captionSize = caption.getPreferredSize();
      caption.setBounds(PADDING, PADDING, captionSize.width, captionSize.height);

      // make all buttons the same size
      Dimension buttonSize = cancelButton.getPreferredSize();
      buttonSize.width = Math.max(buttonSize.width, prevButton.getPreferredSize().width);
      buttonSize.width = Math.max(buttonSize.width, nextButton.getPreferredSize().width);

      // cancel button goes on far left
      cancelButton.setBounds(
          PADDING, size.height - buttonSize.height - PADDING, buttonSize.width, buttonSize.height);

      // prev and next buttons are on the right
      prevButton.setBounds(
          size.width - buttonSize.width * 2 - 6 - PADDING,
          size.height - buttonSize.height - PADDING,
          buttonSize.width,
          buttonSize.height);

      nextButton.setBounds(
          size.width - buttonSize.width - PADDING,
          size.height - buttonSize.height - PADDING,
          buttonSize.width,
          buttonSize.height);

      // calculate size for current page
      Rectangle currentPageBounds = new Rectangle();
      currentPageBounds.x = PADDING;
      currentPageBounds.y = PADDING * 2 + captionSize.height;
      currentPageBounds.width = size.width - currentPageBounds.x - PADDING;
      currentPageBounds.height =
          size.height - buttonSize.height - currentPageBounds.y - PADDING * 2;

      for (int i = 0; i < pages.length; i++) {
        Component page = pages[i];
        page.setBounds(currentPageBounds);
        page.setVisible(i == currentPage);
      }
    }
Exemple #3
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();
    }
  }