Hello guys
Below code mean to display a button with an image on it, the image is real in my computer, but it only displays a blank button. Do you know why?
Many thanks
package brainydraw; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PictureButton extends JFrame { public PictureButton() { setSize(200, 200); setLocation(200, 200); Icon icon = new ImageIcon("Poppy.Jpg"); JButton button = new JButton(icon); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { System.out.println("guess what?"); } }); Container content = getContentPane(); content.setLayout(new FlowLayout()); content.add(button); } public static void main(String[] args) { JFrame f = new PictureButton(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); f.setVisible(true); } }