How to make an invisible border around a JLabel? (JAVA)
border, java, jframe, jlabel, swing
Solution
Simply use an `EmptyBorder`
`title.setBorder(new EmptyBorder(10, 10, 10, 10));`
Check out How to use borders for more examples
Updated
As suggested by Eng.Fouad, you really should be using the `BorderFactory` to generate borders.
`title.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));`
Generally speaking, this can reduce the number of objects created by the application
Problem
I have been searching how to make a border around a JLabel. But I don't want it to have no color. Thanks in advance. ``` public TitlePanel() { title = new JLabel("This is some text!", JLabel.CENTER); add(title); //This will make a black border around the "title" label title.setBorder(new LineBorder(new Color(0,0,0))); } ```