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

JSpinner default editor does not deserialize action map

XMLWordPrintable

    • b10
    • generic
    • generic
    • Verified

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

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 5.2.3790

        A DESCRIPTION OF THE PROBLEM :
        When an instance of JSpinner with a default editor is deserialized, the associated action map is not correctly restored, so when an arrow button is pressed or an up/down key is hit on the deserialized component, nothing happens.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        create a JSpinner.
        serialize the JSpinner to a stream.
        deserialize the JSpinner from the stream.
        add the deserialized JSpinner to a frame.
        make the frame visible.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        when an arrow button is pressed or an up/down key is hit on the deserialized JSpinner, the value in the text field should increase/decrease.
        ACTUAL -
        when an arrow button is pressed or an up/down key is hit on the deserialized JSpinner, nothing happens.

        REPRODUCIBILITY :
        This bug can be reproduced always.

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

        public class JSpinnerBug
        {
            public static void main(String[] args)
            throws IOException, ClassNotFoundException
            {
                // create a JSpinner and set a value
                JSpinner originalSpinner = new JSpinner();
                originalSpinner.setValue(new Integer(1234567890));
                
                // create a memory output stream for testing purpose
                ByteArrayOutputStream memOut = new ByteArrayOutputStream();
                
                // serialize the spinner and close the output stream
                ObjectOutputStream out= new ObjectOutputStream(memOut);
                out.writeObject(originalSpinner);
                out.close();
                
                // now create the memory input stream for deserialization
                ByteArrayInputStream memIn =
                        new ByteArrayInputStream(memOut.toByteArray());
                
                // deserialize the spinner and close the input stream
                ObjectInputStream in = new ObjectInputStream(memIn);
                JSpinner deserializedSpinner = (JSpinner)in.readObject();
                in.close();
                
                // create a frame and add the deserialized spinner
                JFrame frame = new JFrame("Arrows don't work here");
                Container pane = frame.getContentPane();
                pane.setLayout(new FlowLayout());
                
                /*
                 change deserializedSpinner with originalSpinner to see the
                 difference.
                 */
                pane.add(deserializedSpinner);
                
                // show the frame
                frame.setBounds(0, 0, 300, 150);
                frame.setVisible(true);
            }
        }

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

              shickeysunw Shannon Hickey (Inactive)
              igor Igor Nekrestyanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: