-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)

sendStuff:

    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 に答える