package common;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ResourcesToAccess {
public static Icon sharedAbstractDownIcon;
public static Icon sharedAbstractPlayIcon;
public static Icon sharedAbstractPauseIcon;
public static Icon sharedAbstractBlackCursor;
public static Icon sharedAbstractWhiteCursor;
public ResourcesToAccess(){
InputStream is = this.getClass().getClassLoader().getResourceAsStream("/src/images/blackCursor.png");
try{
BufferedImage bi = ImageIO.read(is);
sharedAbstractBlackCursor = (Icon) new ImageIcon(bi);
new JFrame().add(new JLabel(sharedAbstractBlackCursor)).setVisible(true);
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new ResourcesToAccess();
}
}
我正在使用此代码查看是否PNG
可以正确加载图像以创建 JLabels、图标等,但我收到以下错误:
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at common.ResourcesToAccess.<init>(ResourcesToAccess.java:21)
at common.ResourcesToAccess.main(ResourcesToAccess.java:29)
为什么我会看到该错误消息?