title: Does serializing JTextPane's Document, serializes JTextPane's listeners?
body: <p>I'm serializing a <code>JTextPane</code>'s <code>Document</code> in order to persist it's styled text to database. I have a <code>caretListener</code> attached to the <code>JTextPane</code> and I'm wondering if serializing this <code>Document</code> serializies the <code>caretListener</code> as well. The reason why I need to know this is because the custom caretListener class containes <code>JComboBox</code> and I get the following exception when I attempt the serialization:</p>
  
  <pre><code>java.io.NotSerializableException: com.apple.laf.AquaComboBoxUI
  </code></pre>
  
  <p>I suspect that if the Document contains the caretListener, that's the reason for this exception. </p>
  
  <p>Here's the code that serializes it:</p>
  
  <pre><code>DefaultStyledDocument doc = (DefaultStyledDocument) getCellEditor().getCellEditorValue();
  doc.setDocumentFilter(null);
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream oos = new ObjectOutputStream(bos);
  oos.writeObject((DefaultStyledDocument) doc);
  oos.flush();
  
  byte[] data = bos.toByteArray();
  
  oos.close();
  bos.close();
  </code></pre>
  
  <p>And then I'm just saving <code>data</code> in the database.</p>
  
  <p><strong>Addendum</strong></p>
  
  <p>Here's the custom caret listener:</p>
  
  <pre><code>MyTextPane textpane = new MyTextPane();
  textpane.addCaretListener(new caretListener());
  public class caretListener implements CaretListener {
  
      MyTextpane textArea;
      JToggleButton boldbutton;
      JToggleButton italicbutton;
      JToggleButton underlinebutton;
      JComboBox fontscomboBox;
      JComboBox fontSizecombobox;
      // Methods
      ...
  }
  </code></pre>