🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12925

Throw NullPointer Exception when close Dialog

#12925
From: yan zhou
Date: Tue, 20 Oct 1998 00:00
103 lines
3698 bytes
Hi, 

   My Java application keeps throwing NullPointer Exception
whenever I close a Dialog box. I have attached the exception
messages and source code below.

   Thanks for any hints.


				Yan Zhou

Exception occurred during event dispatching:
java.lang.NullPointerException
        at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled
Code)
        at java.awt.LightweightDispatcher.processMouseEvent(Compiled
Code)
        at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
        at java.awt.Container.dispatchEventImpl(Compiled Code)
        at java.awt.Window.dispatchEventImpl(Compiled Code)
        at java.awt.Component.dispatchEvent(Compiled Code)
        at java.awt.EventDispatchThread.run(Compiled Code)



==== Generate a Dialog Box =====

     MsgFrm warnPnl = new MsgFrm(new Frame(), "Checking Messages",true);
     Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
     warnPnl.setLocation((d.width - warnPnl.getSize().width) / 2,
(d.height -  warnPnl.getSize().height) / 2);
     warnPnl.setSize(430,380);

     warnPnl.show();
     warnPnl.lstErrMsg.requestFocus();


==== Dialog Box ======

import java.awt.*;
import com.sun.java.swing.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;
import java.awt.event.*;

public class MsgFrm extends JDialog {
  JPanel panel1 = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  BevelPanel bevelPanel1 = new BevelPanel();

  BevelPanel bevelPanel2 = new BevelPanel();
  static ListControl lstErrMsg = new ListControl();
  BevelPanel bevelPanel3 = new BevelPanel();
  ButtonControl butCloseMsg = new ButtonControl();
  BevelPanel bevelPanel4 = new BevelPanel();
  XYLayout xYLayout1 = new XYLayout();


  public MsgFrm(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try  {
      jbInit();
      pack();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }


  public MsgFrm() {
    this(null, "", false);
  }

  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    butCloseMsg.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        butCloseMsg_actionPerformed(e);
      }
    });
    butCloseMsg.setLabel("Close");
    bevelPanel4.setBevelInner(BevelPanel.FLAT);
    bevelPanel1.setLayout(xYLayout1);
    lstErrMsg.setAutoInsert(false);
    lstErrMsg.setAutoEdit(false);
    lstErrMsg.setBackground(Color.lightGray);
    lstErrMsg.setEditInPlace(false);
    lstErrMsg.setReadOnly(true);
    bevelPanel3.setBevelInner(BevelPanel.FLAT);
    getContentPane().add(panel1);
    panel1.add(bevelPanel1, BorderLayout.CENTER);
    bevelPanel1.add(bevelPanel2, new XYConstraints(2, 2, 414, 262));
    bevelPanel2.add(lstErrMsg, new XYConstraints(0, 0, 411, 258));
    bevelPanel1.add(bevelPanel3, new XYConstraints(2, 264, 415, -1));
    bevelPanel3.add(butCloseMsg, new XYConstraints(152, 2, 87, 30));
    bevelPanel1.add(bevelPanel4, new XYConstraints(2, 298, 413, 56));
  }

  void butCloseMsg_actionPerformed(ActionEvent e) {
    this.dispose();
  }
}
Technical Details
Message-ID: <362CB483.26382519@mtu.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,fd8316c86bc80e53,start
X-Google-Attributes: gid111d45,public
From: yan zhou <yzhou@mtu.edu>
Subject: Throw NullPointer Exception when close Dialog
Date: 1998/10/20
Message-ID: <362CB483.26382519@mtu.edu>
X-Deja-AN: 403220191
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing