-1

这是堆栈的一部分:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at me.lorenjz.com.SerialComms.sendStuff(SerialComms.java:122)
at me.lorenjz.com.MainWindowC.actionPerformed(MainWindowC.java:82)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)

发送资料:

    public synchronized void sendStuff(String messageString){
        //System.out.print("The message being sent is:  " + messageString);
        String stupid = "button";
            try {
122:                output.write(stupid.getBytes());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

    }

这是应该将字符串发送到“sendStuff”的按钮

public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

        //JOptionPane.showMessageDialog(null, "Stuff has happened");
        SerialComms SC = new SerialComms();
        SC.sendStuff("Button");
    }

我在这里做错了什么?

罗兰

添加代码:

    public static void main(String[] args){
     System.out.println("Started onCreate");
     MainWindowC nw = new MainWindowC();
     MixWindowTwo mwt = new MixWindowTwo();
     System.out.println("Started second window");
     SerialComms SC = new SerialComms();
        SC.initialize();

}
4

1 回答 1

1

显然,output尚未创建。

于 2012-09-28T01:58:10.577 回答