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

REGRESSION: Tool Tips don't work after serialize/deserialize

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b78
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The bug occurs when you deserialize a component. The tool tip associated with the component is lost.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.) javac ToolTipTest.java
      2.) java ToolTipTest


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Hover over the buttons in the 3rd window. Tool tips should be displayed.
      ACTUAL -
        Tool tips are only displayed in the first window.

      With JRE 1.4.2 and JRE 1.3.0, Tool tips are displayed in the third window.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.io.*;
      import javax.swing.*;

      /*
       * This class demonstrates 2 bugs in JRE 5.0 update 5. The first bug occurs
       * when you Java serialize a component. The tool tip associated with the
       * component is lost. The second bug occurs when you deserialize a component.
       * The tool tip associated with the component is lost.
       *
       * To witness the behavior, run this class with no arguments. 3 windows will
       * pop up with descriptive title bar's. The original window will have a button
       * with a working tool tip. The middle window is a new window which has been
       * serialized. The tool tips don't work on this one. The third is the
       * reserialization of the second window. Tools tips don't work here either.
       *
       * I believe the first bug could be fixed by adding a
       * ToolTipManager.registerComponent call to the end of the
       * JComponent.writeObject method.
       *
       * I believe the second bug could be fixed by moving the call to
       * ToolTipManager->registerComponent, inside JComponent.readObject, after the
       * client properties have been read.
       *
       */
      public class ToolTipTest extends JFrame
          {

          public static int positionOffset = 0;

          public ToolTipTest (String id)
              {
              setTitle("Tool Tip Test: " + id);

              JButton button =
                  new JButton ("This is a button with tool tip text: " + id);

              getContentPane().add(button);
              button.setToolTipText("Tool Tip Test: " + id);
              getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
              pack();
              setVisible(true);
              this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              positionWindow();
              }

          public void positionWindow ()
              {
              Point position = new Point(positionOffset, positionOffset);
              positionOffset += 100;
              setLocation (position);
              }

          static public void main(String args[])
              {
              try {
                  ToolTipTest toolTipTest = new ToolTipTest("Original");

                  ToolTipTest toolTipTest2 = new ToolTipTest("To be serialized");
                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  ObjectOutputStream oos = new ObjectOutputStream(baos);
                  oos.writeObject(toolTipTest2);

                  ByteArrayInputStream bais = new
                      ByteArrayInputStream(baos.toByteArray());

                  ObjectInputStream oins = new ObjectInputStream(bais);
                  Object o = oins.readObject();

                  ToolTipTest toolTipTest3 = (ToolTipTest) o;
                  toolTipTest3.setTitle("TTT Reserialized");
                  toolTipTest3.setVisible(true);
                  toolTipTest3.positionWindow();
                  }
              catch (Exception ex)
                  {
                  ex.printStackTrace();
                  }
              }
          }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      String t = comp.getToolTipText();
      comp.setToolTipText(null);
      comp.setToolTipText(t);


      Release Regression From : 1.4.2_09
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alexp Alexander Potochkin (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: