BorderFactory: createEmptyBorder(int top,int left,int bottom,int right)
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
public class MainClass {
public static void main(String[] a) {
JFrame frame = new JFrame("Empty Borders");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Border emptyBorder = BorderFactory.createEmptyBorder(20, 20, 0, 0);
JButton emptyButton = new JButton("With Empty");
emptyButton.setBorder(emptyBorder);
JButton nonemptyButton = new JButton("Without Empty");
Container contentPane = frame.getContentPane();
contentPane.add(emptyButton, BorderLayout.NORTH);
contentPane.add(nonemptyButton, BorderLayout.SOUTH);
frame.pack();
frame.setSize(300, frame.getHeight());
frame.setVisible(true);
}
}
Related examples in the same category
1. | BorderFactory: createBevelBorder(int type,Color highlight,Color shadow) | | |
2. | BorderFactory: createCompoundBorder(Border outsideBorder, Border insideBorder) | | |
3. | BorderFactory: createEtchedBorder() | | |
4. | BorderFactory: createLineBorder(Color color) | | |
5. | BorderFactory: createLineBorder(Color color, int thickness) | | |
6. | BorderFactory: createLoweredBevelBorder() | | |
7. | BorderFactory: createMatteBorder(int top, int left, int bottom, int right, Color color) | | |
8. | BorderFactory: createRaisedBevelBorder() | | |
9. | BorderFactory.createTitledBorder(String text) | | |
10. | BorderFactory: createTitledBorder(Border b, String t, int j, int p) | | |