new EmptyBorder(int top, int left, int bottom, int right) : EmptyBorder « javax.swing.border « Java by API






new EmptyBorder(int top, int left, int bottom, int right)

 

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;

public class Main {
  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);
  }
}

   
  








Related examples in the same category