의 null이며, 여기에 배경 이미지 그리기 할 몇 가지 코드 :backgroundImage의 내가 자바 프로그래밍 비교적 새로운 해요 대신 이미지
public class Board extends JPanel{
private static final long serialVersionUID = 4759318639631503071L;
public String room = "menu";
public Image backgroundImage;
public Image getBackgroundImage() throws IOException{
if (room == "menu") {
backgroundImage = ImageIO.read(new File("assets/background_title.png"));
}
return backgroundImage;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(backgroundImage, 0, 0, this);
}
}
내가에서 System.out.println을 사용 또는 backgroundImage가 null 것을 깨달았다를 , 내가 뭘 잘못 했니?
다른 질문은, 어디에서 실행 내용에 관계 자산이다? – MadProgrammer