I am trying to add a picture of a cow and eclipse is failing me. It won't allow any images, I think I may be doing my path wrong, but I am getting it straight from the properties that eclipse supplies upon right-clicking the image. So if anyone has any idea why my picture fails to load please tell me. NO ERROR MESSAGE!
package odin;
import java.awt.event.*;
import javax.swing.*;
public class Main extends JFrame implements ActionListener{
JPanel mypanel;
JButton mybutton;
JLabel mylabel;
int Counter = 0;
public Main(){
mypanel = new JPanel();
mybutton = new JButton("OK");
mybutton.addActionListener(this);
mylabel = new JLabel();
JLabel imgLabel = new JLabel(new ImageIcon("/GuiTest/src/odin/COW.png"));
mypanel.add(mybutton);
mypanel.add(mylabel);
mypanel.add(imgLabel);
this.add(mypanel);
}
public static void main(String[] args){
Main first = new Main();
first.setTitle("First Attempt");
first.setSize(800,600);
first.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
first.setVisible(true);
first.setResizable(false);
first.setLocationRelativeTo(null);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==mybutton)
{
Counter = Counter + 1;
mylabel.setText("My Clicks " + Counter);
}
}
}