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

Event delivery change from JDK 1.3.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs
    • x86
    • windows_nt

      rray(String[] theArray)
        {
          StringBuffer disp = new StringBuffer("");
          for (int i=0; i<theArray.length; i++)
          {
            disp.append("\"" + theArray[i] + "\"");
            if (i<(theArray.length - 1))
            {
              disp.append(",");
            }
          }
          return disp.toString();
        }


      }

      ----------------------------------------------------------------------
      Source code for ValuesDataModel.java
      ----------------------------------------------------------------------
      This is missing... I can send the class file upon request.


      ----------------------------------------------------------------------
      ----------------------------------------------------------------------
      The problem:
      The change in behavior is due to the fix for bug 4150851 being removed from Container.java. With the fix in, events were delivered to the nativeContainer when there was no previous event target. With the fix removed, the events are only delivered to a child component of the nativeContainer, so in the testcase above they never end up getting printed.
      (Review ID: 183979)
      ======================================================================


      Name: pa48320 Date: 04/15/2003


      The following testcase shows a change in behavior for mouse event delivery in JDK 1.4. The TesterBean.class and ValuesDataModel.class are for the java bean itself. They need to live in the <somedir>/oracle/forms/qa directory. The JavaBeanTest class file can just live in <somedir>. To reproduce, compile JavaBeanTest.java and run (I used appletviewer) using JDK 1.3. Notice that the java bean's container is clipping the java bean itself towards the right and the bottom. Move the mouse across the right border or the bottom border of the java bean and see the mouse entered events getting printed. Do the exact same thing using JDK 1.4 and notice that the mouse entered events do not get printed.

      The java bean (TesterBean) is an applet that contains child components. In JDK 1.4, the events only end up going to the child component that the mouse is over.

      ----------------------------------------------------------------------
      ----------------------------------------------------------------------
      Source code for JavaBeanTest.java
      ----------------------------------------------------------------------

      import java.awt.FlowLayout;
      import java.awt.Panel;
      import java.awt.event.MouseEvent;
      import java.awt.event.MouseAdapter;

      import javax.swing.JApplet;
      import javax.swing.JInternalFrame;
      import javax.swing.JPanel;
      import javax.swing.JRootPane;
      import javax.swing.JScrollPane;
      import javax.swing.JTextField;

      import oracle.forms.qa.TesterBean;

      public class JavaBeanTest
             extends JApplet
      {
        JInternalFrame mWindow;
        Panel mBeanContainer;
        JRootPane mContentPane;
        TesterBean mBean;
        JTextField mText;
        MouseEventPrinter mMouseEventPrinter;

        public void start()
        {
          initDesktop();
          initComponents();


          // We now call pack() on the hidden window to resize them to their preferred
          // size. We might also want to add code to position the frame before
          // displaying it. Note: pack() should only be called after the window
          // and all of its ancestors have been added into the component
          // hierarchy. Otherwise, it may not be possible to correctly compute
          // the window's preferred size (eg. the appropriate fonts may not be
          // known).
          mWindow.pack();
          mBeanContainer.setSize(100,100);
          mBean.setSize(mBean.getPreferredSize());

          // Finally, show the window. By default, the newly displayed window will
          // be activated.
          mWindow.setVisible(true);
          mText.requestFocus();
        }


        //
        // Method to initialize the desktop
        //
        public void initDesktop()
        {
          // Create the window
          mWindow = new JInternalFrame();

          mWindow.setTitle("JavaBeanTest Window");

          // Add the windows to the desktop. Note that we use the
          // DesktopContainer.addWindow() method, instead of calling add()
          // directly. The second argument indicates that the frame should be
          // added in a non-visible state.
          getContentPane().add(mWindow);
        }


        //
        // Need a method to create the components
        //
        public void initComponents()
        {
          mText = new JTextField("TextField");

          JPanel intermediateContainer = new JPanel();

          mBeanContainer = new Panel();
          mContentPane = new JRootPane();

          mBean = new TesterBean();

          mBeanContainer.setLayout(null);
          mBeanContainer.add(mBean);

          mContentPane.setLayout(new FlowLayout());

          mContentPane.add(mText);
          mContentPane.add(intermediateContainer);
          intermediateContainer.add(mBeanContainer);

          mWindow.setContentPane(mContentPane);

          mMouseEventPrinter = new MouseEventPrinter();

          //mBeanContainer.addMouseListener(mMouseEventPrinter);
          mBean.addMouseListener(mMouseEventPrinter);
          mBeanContainer.setBackground(java.awt.Color.blue);
        }
      }


      class MouseEventPrinter extends MouseAdapter {
          public void mouseEntered(MouseEvent e) {
              System.out.println("\nmouse entered, e = " + e);
          }
      }

      ----------------------------------------------------------------------
      Source code for TesterBean.java
      ----------------------------------------------------------------------
      package oracle.forms.qa;
      import java.applet.*;
      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.Insets;
      import java.awt.Point;
      import java.awt.Rectangle;
      import java.awt.Component;
      import javax.swing.JScrollPane;
      import javax.swing.JTable;
      import javax.swing.JPanel;
      import java.io.Serializable;
      //Added by ALODHE
      import java.beans.*;

      public class TesterBean extends Applet
      {
        // Constants
        final static int INT_VARIABLE = 0;
        final static int FLOAT_VARIABLE = 1;
        final static int BYTE_VARIABLE = 2;
        final static int DOUBLE_VARIABLE = 3;
        final static int LONG_VARIABLE = 4;
        final static int SHORT_VARIABLE = 5;
        final static int STRING_VARIABLE = 6;
        final static int CHAR_VARIABLE = 7;
        final static int BOOLEAN_VARIABLE = 8;
        final static int COLOR_VARIABLE = 9;
        final static int DIMENSION_VARIABLE = 10;
        final static int INSETS_VARIABLE = 11;
        final static int POINT_VARIABLE = 12;
        final static int RECTANGLE_VARIABLE = 13;
        final static int INTEGER_ARRAY_VARIABLE= 14;
        final static int STRING_ARRAY_VARIABLE = 15;
        final static int CONCAT_METHOD = 16;
        final static int CONCAT_RETURN_METHOD = 17;
        final static int ARRAY_METHOD = 18;
        final static int ARRAY_RETURN_METHOD = 19;


        // Increment the DISPLAY_COUNT if you add an extra Variable
        final static int DISPLAY_COUNT = 20;



        // private "sample" variables that are exposed through getters and setters
        private int intVar;
        private float floatVar;
        private byte byteVar;
        private double doubleVar;
        private long longVar;
        private short shortVar;
        private String stringVar;
        private char charVar;
        private boolean booleanVar;
        private Color colorVar;
        private Dimension dimensionVar;
        private Insets insetsVar;
        private Point pointVar;
        private Rectangle rectangleVar;
        private Integer[] integerArrayVar;
        private String[] stringArrayVar;
        //Added by ALODHE
        private PropertyChangeSupport changes = new PropertyChangeSupport(this);
        



        //UI Elements
        JScrollPane m_tableScrollPanel = new JScrollPane();
        JTable m_valueTable;
        ValuesDataModel m_tableDM;


        public TesterBean()
        {
          super();
          m_tableDM = new ValuesDataModel(DISPLAY_COUNT);
          //initialize the labels
          m_tableDM.setValueAt("int", INT_VARIABLE, 0);
          m_tableDM.setValueAt("float", FLOAT_VARIABLE, 0);
          m_tableDM.setValueAt("byte", BYTE_VARIABLE, 0);
          m_tableDM.setValueAt("double", DOUBLE_VARIABLE, 0);
          m_tableDM.setValueAt("long", LONG_VARIABLE, 0);
          m_tableDM.setValueAt("short", SHORT_VARIABLE, 0);
          m_tableDM.setValueAt("java.lang.String", STRING_VARIABLE, 0);
          m_tableDM.setValueAt("char", CHAR_VARIABLE, 0);
          m_tableDM.setValueAt("boolean", BOOLEAN_VARIABLE, 0);
          m_tableDM.setValueAt("java.awt.Color", COLOR_VARIABLE, 0);
          m_tableDM.setValueAt("java.awt.Dimension", DIMENSION_VARIABLE, 0);
          m_tableDM.setValueAt("java.awt.Insets", INSETS_VARIABLE, 0);
          m_tableDM.setValueAt("java.awt.Point", POINT_VARIABLE, 0);
          m_tableDM.setValueAt("java.awt.Rectangle", RECTANGLE_VARIABLE, 0);
          m_tableDM.setValueAt("java.lang.Integer[]", INTEGER_ARRAY_VARIABLE, 0);
          m_tableDM.setValueAt("java.lang.String[]", STRING_ARRAY_VARIABLE, 0);
          m_tableDM.setValueAt("void concatMethod()", CONCAT_METHOD, 0);
          m_tableDM.setValueAt("String concatMethod()",CONCAT_RETURN_METHOD, 0);
          m_tableDM.setValueAt("void arrayMethod()", ARRAY_METHOD, 0);
          m_tableDM.setValueAt("int arrayMethod()", ARRAY_RETURN_METHOD, 0);

          m_valueTable = new JTable(m_tableDM);
          m_valueTable.setRowHeight(20);


          m_tableScrollPanel.getViewport().add(m_valueTable);
          this.add(m_tableScrollPanel);
        }

        //setters and setters
        public void setIntVar(int theValue)
        {
          int oldIntVar = intVar;
          intVar = theValue;
          displaySet("" + theValue,INT_VARIABLE);
          //Added by ALODHE
          changes.firePropertyChange("intVar", oldIntVar, theValue);

        }

        public int getIntVar()
        {
          return intVar;
        }

        public void setFloatVar(float theValue)
        {
          floatVar = theValue;
          displaySet("" + theValue,FLOAT_VARIABLE);
        }

        public float getFloatVar()
        {
          return floatVar;
        }

        public void setByteVar(byte theValue)
        {
          byteVar = theValue;
          displaySet("" + theValue,BYTE_VARIABLE);
        }

        public byte getByteVar()
        {
          return byteVar;
        }

        public void setDoubleVar(double theValue)
        {
          doubleVar = theValue;
          displaySet("" + theValue,DOUBLE_VARIABLE);
        }

        public double getDoubleVar()
        {
          return doubleVar;
        }

        public void setLongVar(long theValue)
        {
          longVar = theValue;
          displaySet("" + theValue,LONG_VARIABLE);
        }

        public long getLongVar()
        {
          return longVar;
        }

        public void setShortVar(short theValue)
        {
          shortVar = theValue;
          displaySet("" + theValue,SHORT_VARIABLE);
        }

        public short getShortVar()
        {
          return shortVar;
        }

        public void setStringVar(String theValue)
        {
          stringVar = theValue;
          displaySet(theValue,STRING_VARIABLE);
        }

        public String getStringVar()
        {
          return stringVar;
        }

        public void setCharVar(char theValue)
        {
          charVar = theValue;
          displaySet("" + theValue,CHAR_VARIABLE);
        }

        public char getCharVar()
        {
          return charVar;
        }


        public void setBooleanVar(boolean theValue)
        {
          booleanVar = theValue;
          displaySet("" + theValue,BOOLEAN_VARIABLE);
        }

        public boolean getBooleanVar()
        {
          return booleanVar;
        }

        public void setColorVar(Color theValue)
        {
          colorVar = theValue;
          displaySet((theValue.getRed() + " " + theValue.getGreen() + " " + theValue.getBlue()),COLOR_VARIABLE);
        }

        public Color getColorVar()
        {
          return colorVar;
        }

        public void setDimensionVar(Dimension theValue)
        {
          dimensionVar = theValue;
          displaySet("" + theValue.getHeight() + " " + theValue.getWidth(),DIMENSION_VARIABLE);
        }

        public Dimension getDimensionVar()
        {
          return dimensionVar;
        }

        public void setInsetsVar(Insets theValue)
        {
          insetsVar = theValue;
          displaySet((theValue.top + " " + theValue.left + " " + theValue.bottom + " " + theValue.right), INSETS_VARIABLE);
        }

        public Insets getInsetsVar()
        {
          return insetsVar;
        }

        public void setPointVar(Point theValue)
        {
          pointVar = theValue;
          displaySet((theValue.getX() + " " + theValue.getY()), POINT_VARIABLE);
        }

        public Point getPointVar()
        {
          return pointVar;
        }

        public void setRectangleVar(Rectangle theValue)
        {
          rectangleVar = theValue;
          displaySet((theValue.x + " " + theValue.y + " " + theValue.width + " " + theValue.height), RECTANGLE_VARIABLE);
        }

        public Rectangle getRectangleVar()
        {
          return rectangleVar;
        }

        //Array getters and setters

        public int getIntegerArrayCount()
        {
          return integerArrayVar.length;
        }

        public void setIntegerArray(Integer[] theArray)
        {
          integerArrayVar = theArray;
          displaySet(displayIntegerArray(theArray),INTEGER_ARRAY_VARIABLE);
        }

        public Integer[] getIntegerArray()
        {
          return integerArrayVar;
        }

        public void setIntegerArray(int index, Integer theValue)
        {
          if (integerArrayVar == null || index < 0 || index >= getIntegerArrayCount())
          {
            throw new ArrayIndexOutOfBoundsException();
          }

          integerArrayVar[index] = theValue;
          displaySet(displayIntegerArray(integerArrayVar),INTEGER_ARRAY_VARIABLE);
        }

        public Integer getIntegerArray(int index)
        {
          if (integerArrayVar == null || index < 0 || index >= getIntegerArrayCount())
          {
            throw new ArrayIndexOutOfBoundsException();
          }

          return integerArrayVar[index];
        }

        //String Array
        public int getStringArrayCount()
        {
          return stringArrayVar.length;
        }

        public void setStringArray(String[] theArray)
        {
          stringArrayVar = theArray;
          displaySet(displayStringArray(theArray),STRING_ARRAY_VARIABLE);
        }

        public String[] getStringArray()
        {
          return stringArrayVar;
        }

        public void setStringArray(int index, String theValue)
        {
          if (stringArrayVar == null || index < 0 || index >= getStringArrayCount())
          {
            throw new ArrayIndexOutOfBoundsException();
          }

          stringArrayVar[index] = theValue;
          displaySet(displayStringArray(stringArrayVar),STRING_ARRAY_VARIABLE);
        }

        public String getStringArray(int index)
        {
          if (stringArrayVar == null || index < 0 || index >= getStringArrayCount())
          {
            throw new ArrayIndexOutOfBoundsException();
          }

          return stringArrayVar[index];
        }

        // methods

        public void concatMethod(int arg1, int arg2, String arg3, Float arg4)
        {
          String result = new String("" + arg1 + arg2 + arg3 + arg4.toString());
          displaySet(result,CONCAT_METHOD);
        }

        public String concatMethodR(int arg1, int arg2, String arg3, Float arg4)
        {
          String result = new String("" + arg1 + arg2 + arg3 + arg4.toString());
          displaySet(result,CONCAT_METHOD);
          return result;
        }

        public void arrayMethod(String[] strings, Float[] floats)
        {
          StringBuffer sb = new StringBuffer("");
          for (int i=0; i < strings.length; i++)
          {
            sb.append(strings[i]);
          }
          for (int j=0; j < floats.length; j++)
          {
            sb.append(floats[j]);
          }
          displaySet(sb.toString(),ARRAY_METHOD);
        }

        public String arrayMethodR(String[] strings, Float[] floats)
        {
          StringBuffer sb = new StringBuffer("");
          for (int i=0; i < strings.length; i++)
          {
            sb.append(strings[i]);
          }
          for (int j=0; j < floats.length; j++)
          {
            sb.append(floats[j]);
          }
          displaySet(sb.toString(),ARRAY_METHOD);
          return sb.toString();
        }

       //Added by ALODHE

       public void addPropertyChangeListener(PropertyChangeListener l)
       {
           changes.addPropertyChangeListener(l);
       }

       public void removePropertyChangeListener(PropertyChangeListener l)
       {
         changes.removePropertyChangeListener(l);
       }


       





        //Utility stuff
        private void displaySet(String varValue, int varConstant)
        {
          System.out.println("TesterBean> Setting " + m_tableDM.getValueAt(varConstant,0) + " = " + varValue);
          m_tableDM.setValueAt(varValue,varConstant,1);
          this.repaint();
        }

        private String displayIntegerArray(Integer[] theArray)
        {
          StringBuffer disp = new StringBuffer("");
          for (int i=0; i<theArray.length; i++)
          {
            disp.append(theArray[i].toString());
            if (i<(theArray.length - 1))
            {
              disp.append(",");
            }
          }
          return disp.toString();
        }


        private String displayStringA

            dassunw Das Das (Inactive)
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: