Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

java中出现错误:java.lang.NullPointerException?

求助大神帮忙解答:
错误出现在这一行:
g.drawImage(new?ImageIcon(getClass().getResource("image\"+"棋盘.jpg")).getImage(),?90,?60,?625,?700,?this);

控制台显示:
Exception?in?thread?"AWT-EventQueue-0"?java.lang.NullPointerException
at?java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at?DrawUI.paint(DrawUI.java:31)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

读取资源失败呗。要判空呀。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...