这是一个空指针的异常,就是可能有对象没有实例化就被调用!!
1. protected void addAutorunButton() {
2. JButton button = null;
3. button = new JButton(new ImageIcon(Utils.findResource("images/Autorun.gif")));
4. button.addActionListener(new ActionListener() {
5. public void actionPerformed(ActionEvent e) {
6. autorunModule.startAnimation();
7. }
8. });
9. add(button);
10. }我看错误好像出在第6行,autorunModule好像没有初始化,怎么就调用它的方法了呢?
1. protected void addAutorunButton() {
2. JButton button = null;
3. button = new JButton(new ImageIcon(Utils.findResource("images/Autorun.gif")));
4. button.addActionListener(new ActionListener() {
5. public void actionPerformed(ActionEvent e) {
6. autorunModule.startAnimation();
7. }
8. });
9. add(button);
10. }我看错误好像出在第6行,autorunModule好像没有初始化,怎么就调用它的方法了呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货