Exemplo n.º 1
0
    /**
     * Reinitialize the insets parameter with this Border's current Insets.
     *
     * @param c the component for which this border insets value applies
     * @param insets the object to be reinitialized
     */
    public Insets getBorderInsets(Component c, Insets insets) {
      Border border = getBorder();
      if (border != null) {
        if (border instanceof AbstractBorder) {
          ((AbstractBorder) border).getBorderInsets(c, insets);
        } else {
          // Can't reuse border insets because the Border interface
          // can't be enhanced.
          Insets i = border.getBorderInsets(c);
          insets.top = i.top;
          insets.right = i.right;
          insets.bottom = i.bottom;
          insets.left = i.left;
        }
      } else {
        insets.left = insets.top = insets.right = insets.bottom = 0;
      }

      insets.left += EDGE_SPACING + TEXT_SPACING;
      insets.right += EDGE_SPACING + TEXT_SPACING;
      insets.top += EDGE_SPACING + TEXT_SPACING;
      insets.bottom += EDGE_SPACING + TEXT_SPACING;

      if (c == null || label == null) {
        return insets;
      }

      insets.top += label.getHeight();

      return insets;
    }
Exemplo n.º 2
0
 /**
  * Adds a radio button group.
  *
  * @param label group label (or null)
  * @param items radio button labels
  * @param rows number of rows
  * @param columns number of columns
  * @param defaultItem button initially selected
  */
 public void addRadioButtonGroup(
     String label, String[] items, int rows, int columns, String defaultItem) {
   Panel panel = new Panel();
   int n = items.length;
   panel.setLayout(new GridLayout(rows, columns, 0, 0));
   CheckboxGroup cg = new CheckboxGroup();
   for (int i = 0; i < n; i++) {
     Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem));
     cb.addItemListener(this);
     panel.add(cb);
   }
   if (radioButtonGroups == null) radioButtonGroups = new Vector();
   radioButtonGroups.addElement(cg);
   Insets insets = getInsets(5, 10, 0, 0);
   if (label == null || label.equals("")) {
     label = "rbg" + radioButtonGroups.size();
     insets.top += 5;
   } else {
     setInsets(10, insets.left, 0);
     addMessage(label);
     insets.top = 2;
     insets.left += 10;
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = new Insets(insets.top, insets.left, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   if (Recorder.record || macro) saveLabel(cg, label);
   y++;
 }
Exemplo n.º 3
0
  /**
   * The padding between the "content area" (that is, the icon rect and text rect) and the edges of
   * this button. This is a calculated value.
   */
  protected Insets getContentInsets(AbstractButton button) {
    int horizontalPosition = getHorizontalPosition(button);
    int verticalPosition = getVerticalPosition(button);

    Insets i = new Insets(0, 0, 0, 0);
    if (getFocusPainting(button) == PaintFocus.OUTSIDE
        || getFocusPainting(button) == PaintFocus.BOTH) {
      if (horizontalPosition == POS_LEFT || horizontalPosition == POS_ONLY) {
        i.left += focusSize;
      }
      if (horizontalPosition == POS_RIGHT || horizontalPosition == POS_ONLY) {
        i.right += focusSize;
      }
      if (verticalPosition == POS_TOP || verticalPosition == POS_ONLY) {
        i.top += focusSize;
      }
      if (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY) {
        i.bottom += focusSize;
      }
    } else {
      if (fill.getShadowHighlight(button) != null
          && (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY)) {
        i.bottom++;
      }
    }
    return i;
  }
Exemplo n.º 4
0
 /**
  * Layout the receiver. This method set insideBounds & insets according to bounds. Insets is
  * borderWidth + spacing.
  *
  * @see updateDrawableBounds
  */
 protected void layoutComponent() {
   Insets in = (Insets) getInsets().clone();
   in.top += spacing.top;
   in.left += spacing.left;
   in.bottom += spacing.bottom;
   in.right += spacing.right;
   Dimension d = getSize();
   insideBounds.setBounds(
       in.left, in.top, d.width - in.left - in.right, d.height - in.top - in.bottom);
   updateDrawableBounds();
 }
    @Override
    public Insets getInsets(Insets insets) {
      final Insets result = super.getInsets(insets);

      if (UIUtil.isUnderNimbusLookAndFeel() && !isSmallVariant()) {
        result.top += 2;
        result.left += 8;
        result.bottom += 2;
        result.right += 4 + ARROW_ICON.getIconWidth();
      } else {
        result.right += ARROW_ICON.getIconWidth();
      }

      return result;
    }