JLabel添加图像<identifier> expected?</identifier>

时间:2014-01-13 16:17:42

标签: java swing compiler-errors identifier imageicon

// Variables declaration - do not modify
private javax.swing.JLabel image1;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
private javax.swing.JProgressBar progressBar;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
private javax.swing.JLabel titleLabel;
// End of variables declaration

ImageIcon PC1 = new ImageIcon("http://www.blogcdn.com/www.engadget.com/media/2012/06/shazim-pirate-desk-case-mod.jpg");
image1.setIcon(PC1);

我在行"image1.setIcon(PC1);"行收到错误。它告诉我预计会有<identifier>。请帮帮忙?

1 个答案:

答案 0 :(得分:0)

您没有初始化image1对象。