Daniele,
I shared this problem on another Java forum and here's the first answer I
got. I haven't had a chance to try out the suggestion, but here it is:
Posted by Surya Duggirala <[EMAIL PROTECTED]> on June 15, 1998 at 16:19:12:
In Reply to: Problem extending inner classes
In the actionPerformed(ActionEvent) method of Dialog1 class, call
dispose() method after System.out.println(). Then the code will work
properly.
Surya
On Wed, 17 Apr 1996, Daniele Lugli wrote:
> Could somebody try the following application? It raises a null pointer
> exception when class Dialog2, extending class Dialog1, tries to access a
> data member of the outer class.
> Please consider that I am really a java newbie (about 10 days of
> programming) so I'm not saying I've found a bug, the problem is probably
> mine.
>
> Thank you,
> Daniele Lugli
>
>
> // File name: Wrong.java
>
> import java.awt.*;
> import java.awt.event.*;
> import java.lang.String;
> import java.text.*;
> import java.util..*;
>
> public class Wrong extends Frame {
>
> public static void main (String args[]) throws Exception {
> new Wrong ();
> }
>
> public Wrong () throws Exception {
> super ();
> setBounds (300, 100, 300, 100);
> setVisible (true);
>
> i = 5;
>
> new Dialog2 (this);
> }
>
> private void quit () {
> setVisible (false);
> dispose ();
> System.exit (0);
> }
>
>
> class Dialog1 extends Dialog implements ActionListener {
> Dialog1 (Frame parent) {
> super (parent, "Dialog", true );
> setBounds (400, 200, 100, 75);
> okButton = new Button ("OK");
> okButton.addActionListener (this);
> add (okButton);
> setVisible (true);
> }
> public void actionPerformed (ActionEvent aevt) {
>
> System.out.println ("Dialog1: i=" + i);
>
> }
> private Button okButton;
> }
>
> class Dialog2 extends Dialog1 {
> Dialog2 (Frame parent) {
> super (parent);
> }
> public void actionPerformed (ActionEvent aevt) {
> super.actionPerformed (aevt);
>
> System.out.println ("Dialog2: i=" + i);
>
> quit ();
> }
> }
>
> int i;
>
> }
>