Java Utililty Methods JComponent Padding

List of utility methods to do JComponent Padding

  1. HOME
  2. Java
  3. J
  4. JComponent Padding

Description

The list of methods to do JComponent Padding are organized into topic(s).

Method

void addPadding(JComponent comp, int topbottom, int leftright)
Adds padding to a component by creating a Compound Border using the current border and a new empty border with the specified side widths.
addPadding(comp, topbottom, leftright, topbottom, leftright);
JPanel makePaddedPanel(JComponent aComponent, Insets aInsets)
make Padded Panel
return wrapWithBorder(aComponent,
 BorderFactory.createEmptyBorder(aInsets.top, aInsets.left, aInsets.bottom, aInsets.right));
void pad(JComponent component, int w, int h)
pad
Dimension size = component.getPreferredSize();
size.width += w;
size.height += h;
component.setPreferredSize(size);
BufferedImage paint(JComponent jc, int padding)
Paint a JComponent as a BufferedImage
Dimension d = jc.getSize();
BufferedImage bi = new BufferedImage(d.width + 2 * padding, d.height + 2 * padding,
 BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, bi.getWidth(), bi.getHeight());
g.translate(padding, padding);
jc.paint(g);
...
void setComponentHeight(JComponent setme, JComponent getme, int padding)
set Component Height
setme.setPreferredSize(
 new Dimension(getme.getPreferredSize().width, getme.getPreferredSize().height + padding));
void setLeftPadding(JComponent component, int padding)
set Left Padding
component.setBorder(
 BorderFactory.createEmptyBorder(DEFAULT_PADDING, padding, DEFAULT_PADDING, DEFAULT_PADDING));


AltStyle によって変換されたページ (->オリジナル) /