小编use*_*098的帖子

线程"AWT-EventQueue-0"中的异常java.lang.NullPointerException错误

您好,我是一名高中水平的新程序员,因此我对编程知之甚少,并且遇到了一些已经解决的错误,而其他一些我完全不理解.我将制作一个简单的Check Box选择程序,用户可以在各种选择之间进行选择,并根据其动作改变图像.程序本身编译得很完美,但是当我运行它时,它给了我一些复杂性.这是我的计划:

package components;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Workshop extends JPanel
                      implements ItemListener {
JCheckBox winterhatButton;
JCheckBox sportshatButton;
JCheckBox santahatButton;
JCheckBox redshirtButton;
JCheckBox brownshirtButton;
JCheckBox suitButton;
JCheckBox denimjeansButton;
JCheckBox blackpantsButton;
JCheckBox khakipantsButton;


    StringBuffer choices;
JLabel pictureLabel;

public Workshop() {
    super(new BorderLayout());

    //Create the check boxes.
    winterhatButton = new JCheckBox("Winter Hat");
    winterhatButton.setMnemonic(KeyEvent.VK_Q);


    sportshatButton = new JCheckBox("Sports Hat");
    sportshatButton.setMnemonic(KeyEvent.VK_W);


    santahatButton = new JCheckBox("Santa hat");
    santahatButton.setMnemonic(KeyEvent.VK_E);


    redshirtButton = new JCheckBox("Red Shirt");
    redshirtButton.setMnemonic(KeyEvent.VK_R);


    brownshirtButton = new JCheckBox("Brown Shirt"); …
Run Code Online (Sandbox Code Playgroud)

runtime-error nullpointerexception awt-eventqueue drjava

9
推荐指数
1
解决办法
17万
查看次数