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

JInternalFrame not Serializable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs

      This is a duplicate of 4308938, whoops.

      Name: stC104175 Date: 04/26/2000


      java version "1.3.0rc2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc2-Y)
      Java HotSpot(TM) Client VM (build 1.3.0rc2-Y, mixed mode)

      The JInternalFrame throws an exception when trying to serialize it.
      This code:
      *************************
      import java.io.*;
      import javax.swing.*;

      public class JInternalFrameNotSerializable
      {
      public static void main(String args[])
      {
      try {
      UIManager.setLookAndFeel
      (UIManager.getCrossPlatformLookAndFeelClassName());
      } catch (Exception e) {
      System.out.println(e);
      }

      JFrame mainFrame = new JFrame();
      JDesktopPane desktop = new JDesktopPane();
      mainFrame.getContentPane().add(desktop);
      mainFrame.setBounds(200,200,500,500);
      mainFrame.setVisible(true);
      JInternalFrame internalFrame = new JInternalFrame();
      internalFrame.setBounds(50,50,100,100);
      internalFrame.show();
      desktop.add(internalFrame);

      try {
      ObjectOutputStream out = new ObjectOutputStream(

      new BufferedOutputStream(

      new FileOutputStream("serial")));

      out.writeObject(desktop);
      out.close();
      } catch (Exception exc) {
      System.out.println(exc);
      System.exit(1);
      }


      }
      }
      *************************

      Throws this exception:
      *************************
      Exception in thread "main" java.lang.Error: Do not use javax.swing.JInternalFram
      e.setLayout() use javax.swing.JInternalFrame.getContentPane().setLayout() instea
      d
              at javax.swing.JInternalFrame.createRootPaneException(Unknown Source)
              at javax.swing.JInternalFrame.setLayout(Unknown Source)
              at javax.swing.plaf.basic.BasicInternalFrameUI.uninstallListeners(Unknow
      n Source)
              at javax.swing.plaf.basic.BasicInternalFrameUI.uninstallUI(Unknown Sourc
      e)
              at javax.swing.plaf.metal.MetalInternalFrameUI.uninstallUI(Unknown Sourc
      e)
              at javax.swing.JComponent.compWriteObjectNotify(Unknown Source)
              at javax.swing.JInternalFrame.compWriteObjectNotify(Unknown Source)
              at javax.swing.JComponent$EnableSerializationFocusListener.writeObject(U
      nknown Source)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.io.ObjectOutputStream.invokeObjectWriter(Unknown Source)
              at java.io.ObjectOutputStream.outputObject(Unknown Source)
              at java.io.ObjectOutputStream.writeObject(Unknown Source)
      ***********************
      The trace stack is longer but I haven't posted all of it.

      The Serialization process seems to call setLayout() in JInternalFrame which
      throws an exception. It should call getContentPane().setLayout() instead.
      (Review ID: 104018)
      ======================================================================

            Unassigned Unassigned
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: