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

LTP: Not serialize a JButton in xml ( XMLEncoder ) while a tooltip is showed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      FULL PRODUCT VERSION :
      j2sdk1.4.2

      ADDITIONAL OS VERSION INFORMATION :
      Window 2000 service pack 4

      A DESCRIPTION OF THE PROBLEM :
      When is showed a tooltip text on a JButton (i suspect on all Component )
      and in the mean while i create a xml code with XMLEncoder the add method failed.

      This problem cause the lost of this component during the serialize of JFrame parent.

      I think is caused by tooltip manage thread.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Make a class with JFrame and some JButton, whit a tooltip text. Run the sample class below. Press "encode" button and "decode", in the case appears a correctly frame using xmlencoder. Now, move the mouse arrow over the "button" and wait for the tooltip text to be shown. At this point press "encode", and xmlencoder throw an exception; pressing the "decode" button you see the button is lost.

      SOURCE CODE :
      //***********************************************************************************//

      package test;

      /**
       * Autor:Ricky
       * Email:###@###.###
       * Bugid:418583
       */

      import javax.swing.*;
      import java.awt.*;
      import java.beans.*;
      import java.awt.event.*;
      import java.io.*;
      import java.util.*;


      public class Test
      {
       JFrame frame = null;
       JFrame test = null;
       
       public Test ()
       {
        
        test = new JFrame ();
        test.setTitle("Press");
        test.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER) );
        test.setSize(250,80);
        test.setLocation(400,10);
        JButton encode = new JButton("Encode");
        JButton decode = new JButton("Decode");
        
        encode.addActionListener( getActionEncode () );
        decode.addActionListener( getActionDecode () );
        
        test.getContentPane().add( encode );
        test.getContentPane().add( decode );
        test.show();
        
        
        frame = new JFrame ();
        frame.setSize( 300,300 );
        frame.setTitle( "Test" );
        
        JButton button = new JButton ( "Button" );
        button.setToolTipText( "Button Tooltip" );
        button.setBounds(50,50,100,25);
        
        frame.getContentPane().setLayout( null );
        frame.getContentPane().add( button );
        frame.show();
        
        
       }
       
       private ActionListener getActionEncode ( )
       {
        return new ActionListener()
        {
         public void actionPerformed ( ActionEvent ae )
         {
          FileOutputStream fos = null;
          BufferedOutputStream bos = null;
          java.beans.XMLEncoder en = null;
          try
          {
           System.out.println ("ENTER ENCODE");
           fos = new FileOutputStream( new File ("text.xml") );
           bos = new BufferedOutputStream( fos );
           en = new java.beans.XMLEncoder( bos );
           en.writeObject( frame );
           en.flush();
          }
          catch( Exception ex )
          {
           System.out.println ("Exception 1");
           ex.printStackTrace();
          }
          finally
          {
           try
           {
            System.out.println ("CLOSE BUFFER");
            en.close();
            bos.close();
            fos.close();
           }
           catch ( Exception ex )
           {
            System.out.println ("Exception 2");
            ex.printStackTrace();
           }
          }
         }
        };
       }
       
       private ActionListener getActionDecode ( )
       {
        return new ActionListener()
        {
         public void actionPerformed ( ActionEvent ae )
         {
          java.beans.XMLDecoder d = null;
          try
          {
           System.out.println ("ENTER DECODE");
           d = new java.beans.XMLDecoder( new BufferedInputStream (
            new FileInputStream("text.xml")) );
                    ((JFrame)d.readObject()).setLocation(100,100);
          }
          catch( Exception ex )
          {
           System.out.println ("Exception 1");
           ex.printStackTrace();
          }
          finally
          {
           try
           {
            
            d.close();
            
           }
           catch ( Exception ex )
           {
            System.out.println ("Exception 2");
            ex.printStackTrace();
           }
          }
         }
        };
       }


       public static void main(String[] args)
       {
           new Test ();
          }
      }
      //*********************************//

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No Exception
      ACTUAL -
      *********
      EXCEPTION : java.lang.Exception: discarding statement JPanel0.add(JButton0);
      *********
      CAUSE : java.lang.ArrayIndexOutOfBoundsException: 1
      *********

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      ENTER ENCODE
      CLOSE BUFFER
      ENTER DECODE
      ENTER ENCODE
      java.lang.Exception: discarding statement JPanel0.add(JButton0);
      Continuing ...
      CLOSE BUFFER
      ENTER DECODE


      REPRODUCIBILITY :
      This bug can be reproduced always.
      ###@###.### 2005-03-18 22:35:11 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              malenkov Sergey Malenkov (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: