How to put an image on a JButton?
问题 I am writing a program that requires I have a button with an image over top of it, however, so far, I have not been able to get it to work. I have checked several other posts on this site, including How do I add an image to a JButton. My Code: public class Tester extends JFrame { public Tester() { JPanel panel = new JPanel(); getContentPane().add(panel); panel.setLayout(null); setTitle("Image Test"); setSize(300,300); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE);