Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Borderless JButton

DZone's Guide to

Borderless JButton

·
Free Resource
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".
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}