public static void main(String[] args) {
new Test03ImageIconException();
}
public Test03ImageIconException(){
JLabel label = new JLabel("测试");
URL url = Test03ImageIconException.class.getResource("tc.jpg");
assert url != null;
ImageIcon imageIcon = new ImageIcon(url);
label.setIcon(imageIcon);
label.setHorizontalAlignment(SwingConstants.CENTER);
Container contentPane = getContentPane();
contentPane.add(label);
this.setVisible(true);
this.setBounds(220,220,600,420);
//设置关闭事件
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
代码是这么写的,也没有问题啊,标题可以正常显示,显示的效果也是设置的居中效果,为什么图片就是显示不出来呢?
哥们们,帮我看一下,有什么问题么