Marcus,
I've tried to modify my code a little bit, hoping to keep the possibility
to extend the inner class. The idea is: avoid having Dialog1 implementing
ActionListener; give him instead a member function which does everything
actionPerformed should do, but which has a different name, say
myActionPerformed to be original. Then implement ActionListener in the
descendant Dialog2, and call myActionPerformed in its actionPerformed (I
see that it looks a little bit involved, but it's easier to do than to say.
Just see the source hereinafter).
The behaviour changed, but it is still not understandable to me. Neither of
the two System.out.println appears to be executed. Am I doing something
very stupid?

By the way, I sent my previous message both to java-linux and to you,
[EMAIL PROTECTED], but your copy returned back with an error.

Best regards, Daniele



// File name: Test.java

import java.awt.*;
import java.awt.event.*;
import java.lang.String;
import java.text.*;
import java.util.*;

public class Test extends Frame {

  public static void main (String args[]) throws Exception {
    new Test ();
  }

  public Test () 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 {
    Dialog1 (Frame parent) {
      super (parent, "Dialog", true );
      setBounds (400, 200, 100, 75);
      okButton = new Button ("OK");
      add (okButton);
      setVisible (true);
    }
    public void myActionPerformed (ActionEvent aevt) {
      
      System.out.println ("Dialog1: i=" + i);

    }
    public Button okButton;
  }

  class Dialog2 extends Dialog1 implements ActionListener {
    Dialog2 (Frame parent) {
      super (parent);
      okButton.addActionListener (this);
    }
    public void actionPerformed (ActionEvent aevt) {
      super.myActionPerformed (aevt);
      
      System.out.println ("Dialog2: i=" + i);

      quit ();
    }
  }

  int i;

}

Reply via email to