DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Borderless JButton
To create a borderless JButton in swing use the following:
JButton taskButton = new JButton(action); taskButton.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); taskButton.setHorizontalAlignment(JButton.LEADING); // optional taskButton.setBorderPainted(false); taskButton.setContentAreaFilled(false);
This is useful for "hyperlink" style buttons or "task buttons".





