I tried it, with the following amendments:-
Get rid of "public class A." Just call it the main method inside the class Frame.Change the access of class Frame to public.Add the line following after "addActionListener" in the main method:- JOptionPane.showMessageDialog(frame, frame.button.getActionListeners(), "ActionListeners in main", JOptionPane.INFORMATION_MESSAGE);Add the following similar line after addActionListener in the constructor:-JOptionPane.showMessageDialog(this, button.getActionListeners(), "ActionListeners in constructor", JOptionPane.INFORMATION_MESSAGE);I got two JOptionPanes, one saying Frame$1@901887, the second Frame$2@b1937c Frame1@901887. Obviously their hashCodes. Don't know whether this means no 2 was added before no 1.
Then I get this output on the shell:-
[Campbell@dhcppc0 ~]$ javac Frame.java
[Campbell@dhcppc0 ~]$ java Frame
Button listener from: A
Button listener from: Frame
Button listener from: A
Button listener from: Frame
[Campbell@dhcppc0 ~]$ java Frame
Button listener from: A
Button listener from: Frame
and the button changes from "I want this to wait . . ." to "Number: 9999999" after a few seconds.
Might be because the ActionListeners are added in stack order (first in, last out), but otherwise I am not sure what I can suggest which would make any difference if you aren't allowed to change Frame.