@Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
    private void updateCursor(MouseEvent e) {
      Container component = getDisplayerParent();
      Insets insets = component.getInsets();

      boolean valid =
          e.getComponent() == component && e.getY() <= insets.top
              || e.getY() >= component.getHeight() - insets.bottom
              || e.getX() <= insets.left
              || e.getX() >= component.getWidth() - insets.right;

      if (valid) {
        int corner = corner();

        boolean top = e.getY() <= corner;
        boolean left = e.getX() <= corner;
        boolean bottom = e.getY() >= component.getHeight() - corner;
        boolean right = e.getX() >= component.getWidth() - corner;

        if (top && left) {
          setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
          position = Position.NW;
        } else if (top && right) {
          setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
          position = Position.NE;
        } else if (bottom && right) {
          setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
          position = Position.SE;
        } else if (bottom && left) {
          setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
          position = Position.SW;
        } else if (top) {
          int width = component.getWidth();
          if (getConfiguration().isMoveOnBorder()
              && e.getX() > width / 3
              && e.getX() < width / 3 * 2) {
            setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            position = Position.MOVE;
          } else {
            setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
            position = Position.N;
          }
        } else if (bottom) {
          setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
          position = Position.S;
        } else if (left) {
          setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
          position = Position.W;
        } else if (right) {
          setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
          position = Position.E;
        } else {
          setCursor(Cursor.getDefaultCursor());
          position = Position.NOTHING;
        }
      } else {
        setCursor(Cursor.getDefaultCursor());
        position = Position.NOTHING;
      }
      updateBorder();
    }
Ejemplo n.º 3
0
  public void layoutContainer(Container parent) {
    int n = rows.size();
    Insets border = parent.getInsets();
    int lastY = border.top;

    // figure out where the second column should start
    int secondColumn = 0;
    for (int i = 0; i < n; i++) {
      Row r = (Row) rows.get(i);
      if (r instanceof NormalRow) {
        NormalRow nr = (NormalRow) r;
        secondColumn =
            Math.max(
                secondColumn,
                // nr.l.getMinimumSize().width);
                nr.getLabelWidth(false));
      }
    }
    secondColumn += border.left + EXTRA;

    for (int i = 0; i < n; i++) {
      Row r = (Row) rows.get(i);
      if (r instanceof HeaderRow) {
        // header
        Component header = ((HeaderRow) r).h;
        int w = parent.getWidth() - (border.left + border.right);
        int h = header.getMinimumSize().height;
        int x = border.left;
        int y = lastY;
        header.setBounds(x, y, w, h);
        lastY += h;
      } else if (r instanceof NormalRow) {
        // label
        JLabel l = (JLabel) ((NormalRow) r).l;
        int w1 = l.getMinimumSize().width;
        // int h1 =  l.getPreferredSize().height;
        int h1 = l.getMinimumSize().height;
        int x1 = secondColumn - w1;
        int y1 = lastY;
        l.setBounds(x1, y1, w1, h1);

        // control
        Component c = ((NormalRow) r).c;
        // WAS: int w2 = c.getPreferredSize().width;
        int w2 = c.getMaximumSize().width; // NEW!
        w2 = Math.min(w2, parent.getWidth() - (border.right + PADDING + secondColumn));
        int h2 = c.getPreferredSize().height;
        int x2 = secondColumn + PADDING; // buffer between 'em
        int y2 = lastY;
        c.setBounds(x2, y2, w2, h2);

        lastY += Math.max(h1, h2);
      }
    }

    // focus on the first one?  (is that my job?)  (is it even possible?)
  }
    public void layoutContainer(Container parent) {
      final Insets insets = parent.getInsets();
      int x = insets.left;
      int y = insets.top;

      // place the icon
      if (iconLabel != null) {
        Dimension dim = iconLabel.getPreferredSize();
        iconLabel.setBounds(x, y, dim.width, dim.height);
        x += dim.width + 17;
        int leftEdge = x;

        // place the error message
        dummy.setContentType(errorMessage.getContentType());
        dummy.setText(errorMessage.getText());
        dummy.setSize(parent.getWidth() - leftEdge - insets.right, 20);
        dim = dummy.getPreferredSize();
        int spx = x;
        int spy = y;
        Dimension spDim = new Dimension(parent.getWidth() - leftEdge - insets.right, dim.height);
        y += dim.height + 10;
        int rightEdge = parent.getWidth() - insets.right;
        x = rightEdge;
        dim = detailButton.getPreferredSize(); // all buttons should be the same height!
        int buttonY = y + 5;
        if (detailButton.isVisible()) {
          dim = detailButton.getPreferredSize();
          x -= dim.width;
          detailButton.setBounds(x, buttonY, dim.width, dim.height);
        }
        if (detailButton.isVisible()) {
          detailButton.setBounds(x, buttonY, dim.width, dim.height);
        }
        errorScrollPane.setBounds(spx, spy, spDim.width, buttonY - spy);
        if (reportButton.isVisible()) {
          dim = reportButton.getPreferredSize();
          x -= dim.width;
          x -= 5;
          reportButton.setBounds(x, buttonY, dim.width, dim.height);
        }

        dim = closeButton.getPreferredSize();
        x -= dim.width;
        x -= 5;
        closeButton.setBounds(x, buttonY, dim.width, dim.height);

        // if the dialog is expanded...
        if (detailsPanel.isVisible()) {
          // layout the details
          y = buttonY + dim.height + 6;
          x = leftEdge;
          int width = rightEdge - x;
          detailsPanel.setBounds(x, y, width, parent.getHeight() - (y + insets.bottom));
        }
      }
    }
Ejemplo n.º 5
0
 public Dimension getPreferredSize() {
   Dimension d = super.getPreferredSize();
   Container parent = getParent();
   if (parent instanceof JViewport) {
     if (parent.getWidth() > d.width) {
       d = new Dimension(parent.getWidth(), d.height);
     }
   }
   return d;
 }
Ejemplo n.º 6
0
 public Object display() {
   Container parent = null;
   do {
     parent = this.getParent();
   } while (parent == null);
   return this.display(new Dimension(parent.getWidth(), parent.getHeight()));
 }
Ejemplo n.º 7
0
  protected final synchronized void method3570(int var1) {
    Container var2 = this.method3583(685216356);
    if (null != Tile.aCanvas1875) {
      Tile.aCanvas1875.removeFocusListener(this);
      var2.remove(Tile.aCanvas1875);
    }

    Class42.clientWidth = Math.max(var2.getWidth(), Class145.anInt1650 * 2055757083) * -780223189;
    Class116_Sub16.clientHeight =
        Math.max(var2.getHeight(), -1066486805 * PlayerAlias.anInt1758) * 427958731;
    Insets var3;
    if (null != Class116_Sub23_Sub13.aFrame2425) {
      var3 = Class116_Sub23_Sub13.aFrame2425.getInsets();
      Class42.clientWidth -= -780223189 * (var3.left + var3.right);
      Class116_Sub16.clientHeight -= (var3.bottom + var3.top) * 427958731;
    }

    Tile.aCanvas1875 = new Canvas_Sub1(this);
    var2.add(Tile.aCanvas1875);
    Tile.aCanvas1875.setSize(
        -452716157 * Class42.clientWidth, Class116_Sub16.clientHeight * 674167779);
    Tile.aCanvas1875.setVisible(true);
    if (Class116_Sub23_Sub13.aFrame2425 == var2) {
      var3 = Class116_Sub23_Sub13.aFrame2425.getInsets();
      Tile.aCanvas1875.setLocation(
          var3.left + 76231581 * anInt2925, var3.top + anInt2920 * -225353991);
    } else {
      Tile.aCanvas1875.setLocation(76231581 * anInt2925, anInt2920 * -225353991);
    }

    Tile.aCanvas1875.addFocusListener(this);
    Tile.aCanvas1875.requestFocus();
    aBool2921 = true;
    int var4 = -452716157 * Class42.clientWidth;
    int var5 = 674167779 * Class116_Sub16.clientHeight;
    Canvas var6 = Tile.aCanvas1875;

    Object var10;
    try {
      DirectImageProducer var7 = new DirectImageProducer();
      var7.method337(var4, var5, var6, (byte) 1);
      var10 = var7;
    } catch (Throwable var9) {
      RSImageProducer var8 = new RSImageProducer();
      var8.method337(var4, var5, var6, (byte) 1);
      var10 = var8;
    }

    if (Class73.aAbstractRSDrawing_874 != null) {
      Class73.aAbstractRSDrawing_874.method333(
          ((AbstractRSDrawing) var10).finalImage.getGraphics(), 0, 0, -819332484);
    }

    Class73.aAbstractRSDrawing_874 = (AbstractRSDrawing) var10;
    aBool2924 = false;
    aLong2927 = Class116_Sub5.method1929(-1730340736) * -2460302806870968417L;
  }
 @Override
 public void layoutContainer(Container parent) {
   int width = parent.getWidth();
   int height = parent.getHeight();
   Component toolbar = parent.getComponent(0);
   Dimension toolbarSize = toolbar.isVisible() ? toolbar.getPreferredSize() : new Dimension();
   toolbar.setBounds(0, 0, width, toolbarSize.height);
   parent.getComponent(1).setBounds(0, toolbarSize.height, width, height - toolbarSize.height);
 }
 /** @param parent */
 public void layoutContainer(Container parent) {
   Insets insets = parent.getInsets();
   for (int index = 0; index < parent.getComponentCount(); index++) {
     Component comp = parent.getComponent(index);
     comp.setLocation(insets.left, insets.top);
     comp.setSize(
         parent.getWidth() - insets.left - insets.right,
         parent.getHeight() - insets.top - insets.bottom);
   }
 }
Ejemplo n.º 10
0
  @Override
  public void layoutContainer(Container parent) {

    if (parent != container) {
      throw new LayoutException(
          "All layout operations must occur upon this manager's parent container");
    }

    paraboxLayout.doLayout(parent.getWidth(), parent.getHeight(), parent.getComponents());
  }
    private int corner() {
      Container component = getDisplayerParent();
      Insets insets = component.getInsets();

      int corner =
          Math.max(Math.max(insets.top, insets.bottom), Math.max(insets.left, insets.right)) * 5;
      corner = Math.max(25, Math.min(50, corner));

      corner = Math.min(Math.min(component.getHeight() / 2, component.getWidth() / 3), corner);
      return corner;
    }
Ejemplo n.º 12
0
 public int getWidth() {
   float fWidth;
   int width;
   fWidth = scale * nativeGetMaxWidth();
   width = Math.round(fWidth);
   if (parentContainer == null) {
     return width;
   } else {
     return FTAUtilities.max(width, parentContainer.getWidth());
   }
 }
Ejemplo n.º 13
0
 @Override
 public boolean getScrollableTracksViewportWidth() {
   Container parent = getParent();
   if (parent instanceof JViewport) {
     int width = parent.getWidth();
     Dimension min = getMinimumSize();
     Dimension max = getMaximumSize();
     return width >= min.width && width <= max.width;
   }
   return false;
 }
Ejemplo n.º 14
0
  private void posicionaLabel() {

    int x = lastAcessible.getX() + lastAcessible.getWidth() + 3;
    int y = ((int) (lastAcessible.getHeight() + 16) / 2) + lastAcessible.getY() - 16;
    //        label.setLocation(x, control.getY());
    //        label.setLocation(0,0);
    label.setLabelFor(control);
    label.setBounds(x, y, 16, 16);
    //        ((JTextArea) control).setJComponentZOrder(label, 1);
    //            label.setLocation(Integer.parseInt(JOptionPane.showInputDialog("x")),
    // Integer.parseInt(JOptionPane.showInputDialog("y")));
  }
Ejemplo n.º 15
0
  protected Dimension method3584(byte var1) {
    Container var2 = this.method3583(1432588210);
    int var3 = Math.max(var2.getWidth(), 2055757083 * Class145.anInt1650);
    int var5 = Math.max(var2.getHeight(), PlayerAlias.anInt1758 * -1066486805);
    if (Class116_Sub23_Sub13.aFrame2425 != null) {
      Insets var4 = Class116_Sub23_Sub13.aFrame2425.getInsets();
      var3 -= var4.left + var4.right;
      var5 -= var4.bottom + var4.top;
    }

    return new Dimension(var3, var5);
  }
 private static void renderPng(final Container src, final File dst) throws IOException {
   final BufferedImage img =
       new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB);
   final Graphics g = img.getGraphics();
   try {
     // SwingUtilities.paintComponent(g, src, src.getBounds(), null);
     src.paintAll(g);
   } finally {
     g.dispose();
   }
   ImageIO.write(img, "png", dst);
 }
Ejemplo n.º 17
0
    @Override
    public Dimension preferredLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int nmembers = target.getComponentCount();

        Insets insets = target.getInsets();
        // Provide a default if the panel has not been displayed yet (i.e. in a dialog)
        int targetWidth = target.getWidth() == 0 ? 400 : target.getWidth();
        int maxwidth = targetWidth - (insets.left + insets.right + getHgap() * 2);
        int width = 0;
        int height = 0;
        int component = 0;
        for (int i = 0; i < nmembers; i++, component++) {
          Component m = target.getComponent(i);
          if (m.isVisible()) {
            Dimension d = m.getPreferredSize();
            if (component > 0) {
              if (width + d.width > maxwidth) {
                dim.width = Math.max(dim.width, width);
                dim.height += height + getVgap();
                width = 0;
                height = 0;
                component = 0;
              }
              width += getHgap();
            }
            height = Math.max(height, d.height);
            width += d.width;
          }
        }
        dim.width = Math.max(dim.width, width);
        dim.height += height;

        dim.width += insets.left + insets.right + getHgap() * 2;
        dim.height += insets.top + insets.bottom + getVgap() * 2;
        return dim;
      }
    }
Ejemplo n.º 18
0
 private void updateSize(Container target) {
   Dimension sz = null;
   if (_width > 0) {
     sz = calcSizeWithRestriction(_width, target);
   }
   if (sz == null) {
     Insets insets = target.getInsets();
     int width = target.getWidth() - insets.left - insets.right;
     if (width > 0) {
       sz = calcSizeWithRestriction(width, target);
     }
   }
   _preferredLayoutSize = sz != null ? sz : calcSizeNoRestriction(target);
 }
 /**
  * Identifies the coordinates of the 'iconify' button, returning (0, 0) if not found.
  *
  * <p><b>Note:</b> This method is <b>not</b> executed in the event dispatch thread (EDT.) Clients
  * are responsible for invoking this method in the EDT.
  *
  * @param c the target window-like <code>Container</code>.
  * @return the coordinates of the 'iconify' button, returning (0, 0) if not found.
  */
 @RunsInCurrentThread
 static Point iconifyLocationOf(Container c) {
   Insets insets = c.getInsets();
   // From Abbot: We know the exact layout of the window manager frames for w32 and  OSX. Currently
   // no way of detecting
   // the WM under X11. Maybe we could send a WM message (WM_ICONIFY)?
   Point p = new Point();
   p.y = insets.top / 2;
   if (isOSX()) p.x = 35;
   if (isWindows()) {
     int offset = isWindowsXP() ? 64 : 45;
     p.x = c.getWidth() - insets.right - offset;
   }
   return p;
 }
Ejemplo n.º 20
0
  /** {@inheritDoc} */
  public void layoutContainer(final Container parent) {
    synchronized (parent.getTreeLock()) {
      int width = parent.getWidth();
      int height = parent.getHeight();

      Rectangle bounds = new Rectangle(0, 0, width, height);

      int componentsCount = components.size();

      for (int i = 0; i < componentsCount; i++) {
        Component comp = components.get(i);
        comp.setBounds(bounds);
        parent.setComponentZOrder(comp, componentsCount - i - 1);
      }
    }
  }
Ejemplo n.º 21
0
  /*
   * (non-Javadoc)
   *
   * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
   */
  @Override
  public void layoutContainer(final Container c) {
    final Insets in = c.getInsets();
    final int x1 = in.left;
    final int x2 = c.getWidth() - in.right;
    final int y1 = in.top;
    final int y2 = c.getHeight() - in.bottom;
    final Dimension dim = new Dimension(x2 - x1, y2 - y1);

    // System.out.println(dim + " " + c.getWidth() + " " + c.getHeight());
    doRohu(sz, dim, x1, y1);
    doRohu(jz, dim, x1, -y2);
    doRohu(sv, dim, -x2, y1);
    doRohu(jv, dim, -x2, -y2);

    podklad.setBounds(x1, y1, dim.width, dim.height);
  }
Ejemplo n.º 22
0
  public void layoutContainer(Container parent) {
    int divider = getDivider(parent);

    Insets insets = parent.getInsets();
    int w = parent.getWidth() - insets.left - insets.right - divider;
    int x = insets.left;
    int y = insets.top;

    for (int k = 1; k < parent.getComponentCount(); k += 2) {
      Component comp1 = parent.getComponent(k - 1);
      Component comp2 = parent.getComponent(k);
      Dimension d = comp2.getPreferredSize();

      comp1.setBounds(x, y, divider - m_hGap, d.height);
      comp2.setBounds(x + divider, y, w, d.height);
      y += d.height + m_vGap;
    }
  }
Ejemplo n.º 23
0
  public void layoutContainer(Container target) {
    Insets insets = target.getInsets();
    int width = (_width > 0 ? _width : target.getWidth()) - insets.left - insets.right;
    int height = target.getHeight() - insets.top - insets.bottom;
    int x = insets.left;
    int y = insets.top;

    PgmPanel[] ps =
        Arrays.copyOf(target.getComponents(), target.getComponentCount(), PgmPanel[].class);
    _descComparator.setOriginDate(System.currentTimeMillis());
    Arrays.sort(ps, _descComparator);
    for (PgmPanel p : ps) {
      p.setWidth(width);
      int h = p.getPreferredSize().height;
      p.setBounds(x, y, width, h);
      y += h + SEPARATOR_THICKNESS;
    }
  }
Ejemplo n.º 24
0
 public void layoutContainer(Container parent) {
   final int componentCount = parent.getComponentCount();
   final int width = parent.getWidth();
   int y = 0;
   for (int i = 0; i < componentCount; i++) {
     final Component component = parent.getComponent(i);
     if (component.isVisible()) {
       final Dimension preferredCompSize = component.getPreferredSize();
       if (component instanceof MainView) {
         component.setBounds(0, y, width, preferredCompSize.height);
       } else {
         int x = (int) (component.getAlignmentX() * (width - preferredCompSize.width));
         component.setBounds(x, y, preferredCompSize.width, preferredCompSize.height);
       }
       y += preferredCompSize.height;
     }
   }
 }
Ejemplo n.º 25
0
  @Override
  public void layoutContainer(Container target) {

    synchronized (target.getTreeLock()) {
      Insets insets = target.getInsets();

      int top = insets.top;

      int bottom = target.getHeight() - insets.bottom;

      int left = insets.left;

      int right = target.getWidth() - insets.right;

      northHeight = getPreferredDimension(north).height;

      southHeight = getPreferredDimension(south).height;

      eastWidth = getPreferredDimension(east).width;

      westWidth = getPreferredDimension(west).width;

      placeComponents(target, north, left, top, right - left, northHeight, TOP);

      top += (northHeight + getVgap());

      placeComponents(target, south, left, bottom - southHeight, right - left, southHeight, BOTTOM);

      bottom -= (southHeight + getVgap());

      placeComponents(target, east, right - eastWidth, top, eastWidth, bottom - top, RIGHT);

      right -= (eastWidth + getHgap());

      placeComponents(target, west, left, top, westWidth, bottom - top, LEFT);

      left += (westWidth + getHgap());

      if (center != null) {

        center.setBounds(left, top, right - left, bottom - top);
      }
    }
  }
Ejemplo n.º 26
0
 public void layoutContainer(Container parent) {
   Insets insets = parent.getInsets();
   if (parent.getComponentOrientation().isLeftToRight()) {
     int x = insets.left;
     for (Component component : parent.getComponents()) {
       Dimension ps = component.getPreferredSize();
       component.setBounds(
           x, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom);
       x += ps.width - overlap;
     }
   } else {
     int x = parent.getWidth() - insets.right;
     for (Component component : parent.getComponents()) {
       Dimension ps = component.getPreferredSize();
       component.setBounds(
           x - ps.width, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom);
       x += overlap - ps.width;
     }
   }
 }
    /**
     * The preferred size is: The width of the parent container The height necessary to show the
     * entire message text (as long as said height does not go off the screen) plus the buttons
     *
     * <p>The preferred height changes depending on whether the details are visible, or not.
     */
    public Dimension preferredLayoutSize(Container parent) {
      int prefWidth = parent.getWidth();
      int prefHeight = parent.getHeight();
      final Insets insets = parent.getInsets();
      int pw = detailButton.isVisible() ? detailButton.getPreferredSize().width : 0;
      pw += detailButton.isVisible() ? detailButton.getPreferredSize().width : 0;
      pw += reportButton.isVisible() ? (5 + reportButton.getPreferredSize().width) : 0;
      pw += closeButton.isVisible() ? (5 + closeButton.getPreferredSize().width) : 0;
      prefWidth = Math.max(prefWidth, pw) + insets.left + insets.right;
      if (errorMessage != null) {
        // set a temp editor to a certain size, just to determine what its
        // pref height is
        dummy.setContentType(errorMessage.getContentType());
        dummy.setEditorKit(errorMessage.getEditorKit());
        dummy.setText(errorMessage.getText());
        dummy.setSize(prefWidth, 20);
        int errorMessagePrefHeight = dummy.getPreferredSize().height;

        prefHeight =
            // the greater of the error message height or the icon height
            Math.max(errorMessagePrefHeight, iconLabel.getPreferredSize().height)
                +
                // the space between the error message and the button
                10
                +
                // the button preferred height
                closeButton.getPreferredSize().height;

        if (detailsPanel.isVisible()) {
          prefHeight += getDetailsHeight();
        }
      }

      if (iconLabel != null && iconLabel.getIcon() != null) {
        prefWidth += iconLabel.getIcon().getIconWidth();
        prefHeight += 10; // top of icon is positioned 10px above the text
      }

      return new Dimension(
          prefWidth + insets.left + insets.right, prefHeight + insets.top + insets.bottom);
    }
Ejemplo n.º 28
0
    public void layoutContainer(Container parent) {
      synchronized (parent.getTreeLock()) {
        Insets margin = parent.getInsets();
        int x = margin.left;
        int y = margin.top;
        int w = parent.getWidth() - (margin.left + margin.right);
        int h = parent.getHeight() - (margin.top + margin.bottom);
        Component header = findHeader(parent.getComponents());
        if (header != null && header.isVisible()) {
          Dimension dim = header.getPreferredSize();
          header.setBounds(x, y, w, dim.height);
          y += dim.height;
          h -= dim.height;
        }

        Component body = findBody(parent.getComponents());
        if (body != null && body.isVisible()) {
          body.setBounds(x, y, w, h);
        }
      }
    }
Ejemplo n.º 29
0
  /**
   * Lays out the container argument using this border layout.
   *
   * <p>This method actually reshapes the components in the specified container in order to satisfy
   * the constraints of this <code>BorderLayout</code> object. The <code>NORTH</code> and <code>
   * SOUTH</code> components, if any, are placed at the top and bottom of the container,
   * respectively. The <code>WEST</code> and <code>EAST</code> components are then placed on the
   * left and right, respectively. Finally, the <code>CENTER</code> object is placed in any
   * remaining space in the middle.
   *
   * <p>Most applications do not call this method directly. This method is called when a container
   * calls its <code>doLayout</code> method.
   *
   * @param target the container in which to do the layout.
   * @see java.awt.Container
   * @see java.awt.Container#doLayout()
   */
  public void layoutContainer(Container target) {
    synchronized (target.getTreeLock()) {
      Insets insets = target.getInsets();
      int top = insets.top;
      int bottom = target.getHeight() - insets.bottom;
      int left = insets.left;
      int right = target.getWidth() - insets.right;

      boolean ltr = target.getComponentOrientation().isLeftToRight();
      Component c = null;

      if ((c = getChild(NORTH, ltr)) != null) {
        c.setSize(right - left, c.getHeight());
        Dimension d = c.getPreferredSize();
        c.setBounds(left, top, right - left, d.height);
        top += d.height + vgap;
      }
      if ((c = getChild(SOUTH, ltr)) != null) {
        c.setSize(right - left, c.getHeight());
        Dimension d = c.getPreferredSize();
        c.setBounds(left, bottom - d.height, right - left, d.height);
        bottom -= d.height + vgap;
      }
      if ((c = getChild(EAST, ltr)) != null) {
        c.setSize(c.getWidth(), bottom - top);
        Dimension d = c.getPreferredSize();
        c.setBounds(right - d.width, top, d.width, bottom - top);
        right -= d.width + hgap;
      }
      if ((c = getChild(WEST, ltr)) != null) {
        c.setSize(c.getWidth(), bottom - top);
        Dimension d = c.getPreferredSize();
        c.setBounds(left, top, d.width, bottom - top);
        left += d.width + hgap;
      }
      if ((c = getChild(CENTER, ltr)) != null) {
        c.setBounds(left, top, right - left, bottom - top);
      }
    }
  }
Ejemplo n.º 30
0
  @Override
  public void layoutContainer(java.awt.Container target) {
    synchronized (target.getTreeLock()) {
      java.awt.Insets insets = target.getInsets();
      int top = insets.top;
      int left = insets.left;
      int bottom = target.getHeight() - insets.bottom;
      int right = target.getWidth() - insets.right;

      int width = right - left;
      int bottomHeight;
      if (bottomComponent != null) {
        bottomComponent.setSize(width, bottomComponent.getHeight());
        java.awt.Dimension d = bottomComponent.getPreferredSize();
        bottomHeight = d.height;
      } else {
        bottomHeight = 0;
      }

      if (this.mainComponent != null) {
        this.mainComponent.setSize(width, this.mainComponent.getHeight());
        java.awt.Dimension d = this.mainComponent.getPreferredSize();
        if (this.mainComponent instanceof javax.swing.JScrollPane) {
          javax.swing.JScrollPane jScrollPane = (javax.swing.JScrollPane) this.mainComponent;
          if (d.width > (right - left)) {
            d.height += jScrollPane.getHorizontalScrollBar().getPreferredSize().height;
          }
        }

        d.height = Math.min(d.height, bottom - top - bottomHeight);

        this.mainComponent.setBounds(left, top, width, d.height);
        top += d.height + vGap;
      }
      if (bottomComponent != null) {
        bottomComponent.setBounds(left, top, width, bottomHeight);
      }
    }
  }