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

Mouse events killed where "Warning: Applet Window" was

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6, 1.2.1
    • client-libs
    • x86
    • windows_nt



      Name: bk70084 Date: 06/19/98


      In an unsigned applet using Java Plugin with JDK1.1.6, there is a yellow "Warning: Unsigned applet window"
      label at the bottom of the frames. This is fine, but the mouse events are getting killed in that label's
      area in ABSOLUTE screen coordinates, not window-relative. Therefore, when you move the window
      down a bit, there is a dead zone where the warning label used to be.

      The following applet exhibits this problem. It generates a message on the console when the mouse
      is clicked. Start at the top and start clicking downward. When you reach the bottom of the canvas
      (where the warning label would have been if the window was not moved), the events disappear
      This applet is posted at:
      http://209.46.50.168/DeadZone.html

      NOTE: You have to run the plugin ControlPanel to turn on the plugin's Java Console, so you can see when
                 The mouse clicks are registering.
                 On Win32, there should be a menuitem under the Programs menu.


      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;

      public class DeadZone extends Applet implements MouseListener {
        public void init() {
          Frame deadFrame = new Frame("Try clicking near the bottom of the canvas");
          deadFrame.addMouseListener(this);
          deadFrame.setSize(new Dimension(400,200));
          deadFrame.setLocation(new Point(0, 20));
          deadFrame.setVisible(true);
        }

        public void mouseClicked(MouseEvent e) {
          System.out.println("Click! x=" + e.getX() + " y:" + e.getY());
        }
         
        public void mousePressed(MouseEvent e) {}
        public void mouseReleased(MouseEvent e) {}
        public void mouseEntered(MouseEvent e){}
        public void mouseExited(MouseEvent e){}
      }

      This problem shows up in JRE1.1.6 stuff-
      AppletViewer 1.1.6, Java Plug-In 1.1

      on the Win32 platform. I haven't been able to test it on other platforms.
      (Review ID: 32404)
      ======================================================================

      Name: dbT83986 Date: 05/30/99




      When my JApplet creates a JDialog, sets its location, and then
      shows it, an area within the dialog doesn't respond to mouse
      events. This is usually seen in JTextFields which I cannot click
      to focus. They DO accept focus if I tab to them.

      IMPORTANT COMMENTS:

      1.) The problem only exists in JDialogs displaying the yellow
      warning banner. If I add the following line to my java.policy
      file, there is no problem:

      permission java.awt.AWTPermission "showWindowWithoutWarningBanner";

      Also, there is no problem if I am running as an application and
      not as an applet.

      2.) If I convert my little test applet to use all AWT components
      and no Swing components, there is no problem.

      3.) If I do not call setLocation() or one of its deprecated
      cousins, there is no problem. I have a substantial GUI, and
      having many windows crammed into (0,0) isn't much of a workaround.

      4.) Moving or resizing the window manually may correct or partially
      correct the problem, but is quite irritating.

      5.) This bug is the most often mentioned bug from our users.

      VERSION INFO:

      C:\>java -version
      java version "1.2.1"
      Classic VM (build JDK-1.2.1-A, native threads)

      C:\>java -fullversion
      java full version "JDK-1.2.1-A"

      DEMONSTRATION CODE:

      The listings below will display a JDialog containing 20
      JTextFields in 2 columns. The fields are labeled for convenience.
      The text fields are listened to by a MouseAdapter. The adapter
      will display a message when the components are entered or exited.
      The message will show the coordinate where the event occurred.

      You will find that TextField-16 shows no mouse events at all!
      TextField-17 will respond to mouse movement except in its
      leftmost 19 pixels!

      This problem is also seen in our applet to disable clicking on
      some buttons.

      Listing 1
      ----------

      import javax.swing.*;

      public class WarningApplet extends JApplet
      {
         public void init()
         {
            JFrame frame = new JFrame();
            JDialog dlg = new WarningDialog(frame);
            dlg.setLocation(50,50);
            dlg.setVisible(true);
         }
      }


      Listing 2
      ----------

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class WarningDialog extends JDialog
      {
         public WarningDialog(Frame frame)
         {
            super(frame, "WarningBanner Dialog");
            
            Container cont = getContentPane();
            cont.setLayout(new GridLayout(10,1,5,5));
            
            MouseHandler mouseHandler = new MouseHandler();
            
            String desc;
            JTextField field;
            
            for( int i = 0 ; i < 20 ; i++ )
            {
               desc = "TextField-" + i;
               
               field = new JTextField(desc);
               field.setName(desc);
               field.addMouseListener(mouseHandler);
               
               cont.add(field);
            }
            
            pack();
         }
         
         class MouseHandler extends MouseAdapter
         {
            public void mouseEntered(MouseEvent event)
            {
               System.out.println(((Component)event.getSource()).getName() +
                  " Entered at: " + event.getPoint());
            }
            
            public void mouseExited(MouseEvent event)
            {
               System.out.println(((Component)event.getSource()).getName() +
                  " Exited at: " + event.getPoint());
            }
         }
      }
      (Review ID: 83640)
      ======================================================================

            rramsunw Ranganathan Ram (Inactive)
            bklocksunw Brian Klock (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: