Creating Empty using its Constructor : EmptyBorder « Swing « Java Tutorial






EmptyBorder is a border with nothing drawn in it.

Creating Empty using its Constructor
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;

public class EmptyBorderSample {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Sample Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border emptyBorder = new EmptyBorder(5, 10, 5, 10);
    
    JLabel aLabel = new JLabel("Bevel");
    aLabel.setBorder(emptyBorder);
    aLabel.setHorizontalAlignment(JLabel.CENTER);

    frame.add(aLabel);
    frame.setSize(400, 200);
    frame.setVisible(true);
  }
}








14.105.EmptyBorder
14.105.1.Empty BorderEmpty Border
14.105.2.Creating Empty using its ConstructorCreating Empty using its Constructor
14.105.3.Adding EmptyBorder to a JButtonAdding EmptyBorder to a JButton
14.105.4.Creating and Setting an Empty Border from BorderFactory