0 LIKES LikeUnLike
I have knocked up a test program to fiddle with images in swing but cant get the image to show in a button on the pane although it shows in the top bar hence the path is right .. any suggestions as to what I am doing wrong.The code sample is as follows:package swingTest2;import java.net.URL;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;public class SwingTest2 extends JFrame{ public SwingTest2() { // TODO Auto-generated constructor stub super("Test Window"); setSize(300,300); setDefaultCloseOperation(JFrame.EXIT... JPanel pane = new JPanel(); URL resourceLocation = getClass().getResource("/images/load.gif... ImageIcon icon = new ImageIcon(resourceLocation); setIconImage(icon.getImage()); JButton load = new JButton("Load"); JButton save = new JButton("Save"); pane.add(load,icon); add(pane); setVisible(true); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stubSwingTest2 s = new SwingTest2();} }
Tags:
Report (0) (0) | earlier
Latest activity: earlier. This question has 1 answers.