Here you can find the source of addPadding(JComponent comp, int topbottom, int leftright)
Parameter | Description |
---|---|
comp | Component to Pad |
topbottom | Top and Bottom Padding |
leftright | Left and Right Padding |
public static void addPadding(JComponent comp, int topbottom, int leftright)
//package com.java2s; //License from project: Open Source License import javax.swing.BorderFactory; import javax.swing.JComponent; public class Main { /**//from w ww . j a va 2s.c o m * Adds padding to a component by creating a Compound Border using * the current border and a new empty border with the specified side widths. * * @param comp Component to Pad * @param top Top Padding * @param right Right Padding * @param bottom Bottom Padding * @param left Left Padding */ public static void addPadding(JComponent comp, int top, int right, int bottom, int left) { comp.setBorder(BorderFactory.createCompoundBorder(comp.getBorder(), BorderFactory.createEmptyBorder(top, left, bottom, right))); } /** * Adds padding to a component by creating a Compound Border using * the current border and a new empty border with the specified side widths. * * @param comp Component to Pad * @param topbottom Top and Bottom Padding * @param leftright Left and Right Padding */ public static void addPadding(JComponent comp, int topbottom, int leftright) { addPadding(comp, topbottom, leftright, topbottom, 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. * * @param comp Component to Pad * @param all Padding for All Sides */ public static void addPadding(JComponent comp, int all) { addPadding(comp, all, all, all, all); } }