Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4242611

explicit event enabling in JButton created in an inner class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2
    • tools
    • x86
    • windows_98



      Name: krT82822 Date: 05/30/99


      ERROR: sun.tools.java.CompilerError: stack under flow: 53: invokespecial ExplicitEvent. 1$MyButton(ExplicitEvent,java.lang.String,javax.swing.Icon) = -1
      -- listing --
      $18:
      53: aload 0
      53: aload 3
      53: aload 4
      53: invokespecial ExplicitEvent. 1$MyButton(ExplicitEvent,java.lang.String,javax.swing.Icon)
      53: return
      sun.tools.java.CompilerError: stack under flow: 53: invokespecial ExplicitEv
      ent. 1$MyButton(ExplicitEvent,java.lang.String,javax.swing.Icon) = -1
              at sun.tools.asm.Assembler.balance(Assembler.java:249)
              at sun.tools.asm.Assembler.write(Assembler.java:381)
              at sun.tools.javac.SourceClass.compileClass(SourceClass.java:2410)
              at sun.tools.javac.SourceClass.compile(SourceClass.java:2039)
              at sun.tools.javac.Main.compile(Main.java:567)
              at sun.tools.javac.Main.main(Main.java:733)
      error: An error has occurred in the compiler; please file a bug report (http://j
      ava.sun.com/cgi-bin/bugreport.cgi).
      1 error
      --------------------------------------------------------------
      C:\work>java -version
      java version "1.2.1"
      HotSpot VM (1.0fcs, mixed mode, build E)
      --------------------------------------------------------------
      C:\work>java -fullversion
      JAVA.EXE full version "JDK-1.2.1-A"
      --------------------------------------------------------------
      /*
       *ExplicitEvent.java
       *
       */
       //package friendly XXX
       import javax.swing.*;
       import java.awt.*;
       import java.awt.AWTEvent;
       import java.awt.event.*;
      /**
       *This class is a practice for explicit
       *event enabling.
       *
       *Problem: Wheather Swing or AWT,
       *the compiler generates a
       *reportable bug.
       *
       *Should this be caused by a programming error
       *I would greatly appreciate your reply.
       *
       *@version 5/29/99 12:29PM
       *@author Florin Gheorghies, Portland, OR
       */
       public class ExplicitEvent extends JFrame
        implements WindowListener {
       
      private JLabel label;
      private JButton button;
      private Image image;

      /**
      * Constructs a <code>JFrame</code> as the root
      * of the program's containment hierarchy.
      */
      public ExplicitEvent(String titleString) {
      super(titleString);
      // getContentPane(add(getButton(), BorderLayout.NORTH); // ORIG
               getContentPane().add(getButton(), BorderLayout.NORTH); // kevin.ryan@eng 5/30/99
        setBounds(200, 100, 300, 300);
      setVisible(true);
      }

      /**
      *Creates and returns a button that handles its own events
      */
      private Component getButton () {
      /*all activity is local, artifact complete */
      final String text = "Press Me!";
      final Icon icon = new ImageIcon("action.gif");

      class MyButton extends JButton {
      Icon image2 = new ImageIcon("wallmart.gif");

      private MyButton (String text_, Icon icon_) {
      super(text_, icon_);
      enableEvents(AWTEvent.ACTION_EVENT_MASK);
      System.out.println("The button is being initialized...");
      System.out.println("The AWTEvent is being enabled...");
      }
      //Atention! processActionEvent from the AWT package,
      //produces the same error:
      public void processEvent(ActionEvent ae) {
      super.processEvent(ae);

      label = new JLabel(image2);

      if (ExplicitEvent.this.isShowing()) {
      System.out.println("JFrame is being checked " +
      "for active...");
      ExplicitEvent.this.add(label, BorderLayout.CENTER);
      System.out.println("Label has been added to " +
      "the frame.");
      }
      }
      }
      return new MyButton(text, icon);
      }

      public static void main (String[] args) {
      ExplicitEvent ee = new ExplicitEvent("ExplicitEvent");
      }
      //FIXME: make use of these methods for the fun of it
      public void windowActivated(WindowEvent we) {}
      public void windowClosed(WindowEvent we) {}
      public void windowDeactivated(WindowEvent we) {}
      public void windowDeiconified(WindowEvent we) {}
      public void windowIconified(WindowEvent we) {}
      public void windowOpened(WindowEvent we) {}
      public void windowClosing(WindowEvent we) {
      System.out.println("Program is now being closed...");
      System.exit(0);
      }
      }
      --------------------- end of file -----------------------
      (Review ID: 83647)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: