public class testt extends JApplet{
JButton butt=null;
JPanel p=null;
public void init()
{
String host=this.getCodeBase().getHost();
this.getContentPane().add(new JLabel(host));
this.setSize(500,500);
this.setContentPane(getPane());
}
private JPanel getPane()
{
p=new JPanel();
butt=new JButton();
URL urlIcon=getClass().getResource("/images/zoomin.JPG");
Icon butticon=new ImageIcon(urlIcon);//出现空指针的地方
butt.setIcon(butticon);
p.add(butt);
return p;
}
}
urlIcon是空的,也就是getClass().getResource("/images/zoomin.JPG");没返回URL的值,帮我看看错在哪里了?(路径是正确的)