我不确定问题出在哪里。是在路上吗?尽管代码语法中完全没有错误,但图像未显示。我应该提供整个路径还是只将图像放在目录中并调用它的名称?谢谢你。
public class NetworkingGame {
private JFrame jfrm;
NetworkingGame(){
jfrm = new JFrame("Angry Painters");
jfrm.setSize(800, 480);
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jfrm.setVisible(true);
}// end of constructor
public void ImageLoading(){
ImageIcon i = new ImageIcon("C:/Users/TOSHIBA/Documents/NetBeansProjects/NetworkingGame/build/classes/angry-painters.jpeg");
JLabel jl = new JLabel(i);
jfrm.add(jl);
}
public static void main(String[] args) throws Exception{
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
NetworkingGame ng = new NetworkingGame();
ng.ImageLoading();
} // end of run method
}); // end of Runnable
}//end of main method
}//end of class NetworkingGame