Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NullPointerException Using AWT for 1.3: Please Help

1 view
Skip to first unread message

rkin...@my-deja.com

unread,
May 10, 2000, 3:00:00 AM5/10/00
to
Hi,

I am getting the following exception when using awt with JDK 1.3:

=================
Exception Details
=================

Exception occurred during event dispatching:
java.lang.NullPointerException: null pData
at sun.awt.windows.WInputMethod.handleNativeIMEEvent(Native Method)
at sun.awt.windows.WInputMethod.dispatchEvent(Unknown Source)
at sun.awt.im.InputContext.dispatchEvent(Unknown Source)
at sun.awt.im.InputMethodContext.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Further Details are as follows:

===================
Program Description
===================

I am creating an application which uses a frame. I am initialising a
Panel which contains two textfield components( first Name and last name)
and two corresponding lables. The panel also contains a button called
"test". This panel is added to the frame.

The functionality of the button is to remove the panel from the frame,
and add it back to it( may sound little ridiculous, but, i am just
giving a simple example of my application. Actually, I want to remove
the current panel and add another depending on the event performed ).


The application is written using AWT. I know we are supposed to use
swing, but wanted to test something with AWT.

==================
Execution Scenario
==================
* Run the application.
* The cursor comes is in the text field of First Name.
* Click on the "Test" Command button
* Move the mouse pointer over to the Text field( first Name )
* This generates a NullPointerException. As a consequence I cannot do
anything in the text field.
* Move the mouse pointer from the TextField, exceptions are not raised.
* Click in the second TextField( Last Name ).
* No Exception raised.
* Now everything seems to work fine.
* Have the cursor in the second text field.
* Click on the Button, and move the mouse pointer over the second text
field
* NullPointerException are raised.

Seems like if I move the mouse pointer over to the text area which was
active below clicking the "test" button causes the exceptions to be
raised.

==========
Questions:
==========

* May I know what is causing the NullPointerException and why?
* Am I doing something wrong or missing something( other than using
swing )?
* How to avoid it if using AWT in JDK 1.3?
( Assumping I have to use only AWT )

=========
Platform:
=========

* Windows NT

=============
Observations:
=============
* This problem was observed with JDK 1.3
* Works fine with JDK 1.2
* Works fine with swing.


Thanks in Advance
-Ramakrishna Kintada

=============
Code Segment
=============

import java.lang.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;

public class Main extends Frame implements ActionListener
{
private Panel tempPanel = new Panel();
private Button cmdTest = new Button( "Test" );
private TextField txtFName = new TextField( "", 20 );
private TextField txtLName = new TextField( "",20 );

public void initPanel()
{
tempPanel.setLayout( new GridLayout( 3,2 ) );
cmdTest.addActionListener( this );

Label lblFName = new Label( "First Name" );

Label lblLName = new Label( "Last Name" );

tempPanel.add( lblFName );
tempPanel.add( txtFName );
tempPanel.add( lblLName );
tempPanel.add( txtLName );
tempPanel.add( cmdTest );

}

public void init()
{
setLayout( new FlowLayout() );
initPanel();
add( tempPanel );
}

public void actionPerformed( ActionEvent e )
{
if( e.getSource() == cmdTest )
{
removeAll();

txtFName.setText("");
txtLName.setText("");

System.out.println( " Test Button Clicked " );
add( tempPanel );
show();
}
}

public Main()
{
init();
}

public static void main( String[] args )
{
Main m = new Main();
m.pack();
m.setSize(800, 600);
m.show();
}
}

Sent via Deja.com http://www.deja.com/
Before you buy.

Sai Pulugurtha

unread,
May 10, 2000, 3:00:00 AM5/10/00
to
I too noticed the same problem. Probably some one who implemented jvm
or awt should be able to answer this.

Or is there anyway we can submit this question to the folks in sun?

Thanks,
Sai

In article <8fa9de$dor$1...@nnrp1.deja.com>,

0 new messages