I want to load animated gif to jpanel so I read how to do it but when I run the program
i get this message:
java.net.MalformedURLException: no protocol: /Users/me/Documents/workspace/ManageTimeClock/Images/timeanim.gif
I checked my gif path and its correct!!
So what should i do?
my code:
URL url;
try {
url = new URL("/Users/me/Documents/workspace/ManageTimeClock/Images/timeanim.gif");
Icon imgGif = new ImageIcon(url);
JLabel lblGif = new JLabel();
lblGif.setIcon(imgGif);
lblGif.setBounds(100, 100, 400, 450);
switchPanel.add(lblGif);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
i solved it thank to all anyway :)
solved it with:
String path = "/Users/me/Documents/workspace/ManageTimeClock/Images/timeanim.gif";
Icon imgGif = new ImageIcon(path);
JLabel lblGif = new JLabel();
lblGif.setIcon(imgGif);
lblGif.setBounds(150,150, 455, 170);
switchPanel.add(lblGif);