EmptyBorderForLabel.java Source code

Java tutorial

Introduction

Here is the source code for EmptyBorderForLabel.java

Source

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class EmptyBorderForLabel extends JFrame {

    public EmptyBorderForLabel() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
        JLabel label;

        label = new JLabel("Empty");
        label.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
        panel.add(label);
        getContentPane().add(panel);
        pack();
    }

    public static void main(String[] args) {
        EmptyBorderForLabel s = new EmptyBorderForLabel();
        s.setVisible(true);
    }
}