日期:2014-05-20  浏览次数:20699 次

jbuilder2005编译老出现空指针异常,请大虾帮帮看看源代码。感激不尽
package   simpletalk;

import   java.awt.*;
import   javax.swing.*;
import   com.borland.jbcl.layout.XYLayout;
import   com.borland.jbcl.layout.*;
import   java.net.*;
import   java.awt.event.ActionEvent;
import   java.awt.event.ActionListener;

/**
  *   <p> Title:   </p>
  *
  *   <p> Description:   </p>
  *
  *   <p> Copyright:   Copyright   (c)   2007 </p>
  *
  *   <p> Company:   </p>
  *
  *   @author   not   attributable
  *   @version   1.0
  */
public   class   Frame1
        extends   JFrame   {
    JPanel   contentPane;
    XYLayout   xYLayout1   =   new   XYLayout();
    JButton   jButton1   =   new   JButton();
    JLabel   jLabel1   =   new   JLabel();
    JLabel   jLabel2   =   new   JLabel();
    JScrollPane   jScrollPane1   =   new   JScrollPane();
    JTextArea   jTextArea1   =   new   JTextArea();
    XYLayout   xYLayout2   =   new   XYLayout();
    JScrollPane   jScrollPane2   =   new   JScrollPane();
    JTextArea   jTextArea2   =   new   JTextArea();
    DatagramPacket   sendPacket,receivePacket;
    DatagramSocket   sender,receiver;
    JTextField   jTextField1   =   new   JTextField();
    public   Frame1()   {
        try   {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
            startChat();
        }
        catch   (Exception   exception)   {
            exception.printStackTrace();
        }
    }

    /**
      *   Component   initialization.
      *
      *   @throws   java.lang.Exception
      */
    private   void   jbInit()   throws   Exception   {
        contentPane   =   (JPanel)   getContentPane();
        contentPane.setLayout(xYLayout2);
        setSize(new   Dimension(400,   300));
        setTitle( "Frame   Title ");
        jButton1.setText( "发送 ");
        jButton1.addActionListener(new   Frame1_jButton1_actionAdapter(this));
        jLabel1.setText( "好友 ");
        jLabel2.setText( "消息 ");
        jTextField1.setText( "jTextField1 ");
        contentPane.add(jLabel2,   new   XYConstraints(24,   232,   -1,   -1));
        contentPane.add(jLabel1,   new   XYConstraints(83,   15,   -1,   -1));
        contentPane.add(jScrollPane2,   new   XYConstraints(69,   226,   167,   57));