@Override public Insets getBorderInsets(Component c) { Dimension size = comp.getPreferredSize(); Insets insets = border.getBorderInsets(c); insets.top = Math.max(insets.top, size.height); return insets; }
/** * 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; }
/** * 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++; }
@Override public Insets getInsets() { Insets insets = super.getInsets(); if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel() && isEditable) { insets.right += 2; } return insets; }
@Override public Insets getInsets() { Insets insets = super.getInsets(); if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) { insets.top += 1; insets.bottom += 2; } return insets; }
/** * 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(); }
/** * Request the window insets from the delegate and compares it with the current one. This method * is mostly called by the delegate, e.g. when the window state is changed and insets should be * recalculated. * * <p>This method may be called on the toolkit thread. */ public final boolean updateInsets(final Insets newInsets) { synchronized (getStateLock()) { if (insets.equals(newInsets)) { return false; } insets = newInsets; } return true; }
/** * Returns a string representation of this <code>JPopupMenu</code>. This method is intended to be * used only for debugging purposes, and the content and format of the returned string may vary * between implementations. The returned string may be empty but may not be <code>null</code>. * * @return a string representation of this <code>JPopupMenu</code>. */ protected String paramString() { String labelString = (label != null ? label : ""); String paintBorderString = (paintBorder ? "true" : "false"); String marginString = (margin != null ? margin.toString() : ""); String lightWeightPopupEnabledString = (isLightWeightPopupEnabled() ? "true" : "false"); return super.paramString() + ",desiredLocationX=" + desiredLocationX + ",desiredLocationY=" + desiredLocationY + ",label=" + labelString + ",lightWeightPopupEnabled=" + lightWeightPopupEnabledString + ",margin=" + marginString + ",paintBorder=" + paintBorderString; }
@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; }
public Insets getBorderInsets(Component c, Insets insets) { insets.set(2, 2, 2, 2); return insets; }
/** * 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; }