To answer this question correctly, SSCCE is most likely required. In any case, I believe that you will want to call setContentAreaFilled(false) on your JButton instances. This should effectively remove the "square".
However, it is important to note that the exact behavior of calling this function depends on the component by component and the basis of L & F-by-L & F.
import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; public final class JButtonDemo { public static void main(String[] args){ SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { createAndShowGUI(); } }); } private static void createAndShowGUI(){ final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JIconButton()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } private static final class JIconButton extends JButton{ private static final long serialVersionUID = 7274140930080397481L; public JIconButton(){ super(UIManager.getIcon("OptionPane.informationIcon")); setContentAreaFilled(false); setFocusPainted(false); setBorder(BorderFactory.createEmptyBorder()); } } }

source share