Exemplo n.º 1
0
 private void hideDropDownButton() {
   for (Component component : this.getComponents()) {
     if (component instanceof AbstractButton && component.isVisible()) {
       component.setVisible(false);
       this.revalidate();
     }
   }
 }
Exemplo n.º 2
0
 private void toggleViewState(final Component component, final boolean visible) {
   final Dimension size = getSize();
   size.height += component.getSize().height * (visible ? -1 : 1);
   component.setVisible(!visible);
   setMinimumSize(size);
   if ((getExtendedState() & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
     pack();
   }
 }
Exemplo n.º 3
0
 // not used
 public Component add(Component c) {
   // System.out.println("Add " + c);
   if (c instanceof AbstractButton) {
     // System.out.println("Add to button group " + c);
     c.setVisible(true);
     bg.add((AbstractButton) c);
   }
   if (c instanceof Anchorable && ((Anchorable) c).isAnchored()) {
     c.setSize(c.getPreferredSize());
   }
   return super.add(c);
 }
Exemplo n.º 4
0
 protected void hide0() {
   JRootPane rp = null;
   if (getOwner() instanceof JFrame) {
     rp = ((JFrame) getOwner()).getRootPane();
   } else if (getOwner() instanceof JDialog) {
     rp = ((JDialog) getOwner()).getRootPane();
   }
   if (rp != null && !isDocumentModalitySupported() && !isExperimentalSheet()) {
     Component blockingComponent = rp.getGlassPane();
     blockingComponent.setVisible(false);
     if (ownersGlassPane != null) {
       rp.setGlassPane(ownersGlassPane);
       ownersGlassPane = null;
     }
   }
   super.hide();
 }
Exemplo n.º 5
0
    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);
      }
    }
Exemplo n.º 6
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();
    }
  }