javax.swing
Class JComponent.EnableSerializationFocusListener

java.lang.Object
  extended byjavax.swing.JComponent.EnableSerializationFocusListener
All Implemented Interfaces:
EventListener, FocusListener, Serializable
Enclosing class:
JComponent

private class JComponent.EnableSerializationFocusListener
extends Object
implements FocusListener, Serializable

This class is used to give us an opportunity to uninstall the UI before java.awt.Container.writeObject runs. The enableSerialization method below adds an instance of this class to the FocusListener field in java.awt.Component. The java.awt.Component.writeObject method, which always runs before java.awt.Container.writeObject, effectively calls our writeObject method, which takes care of uninstalling the UI.

A FocusListener is used (any listener would do) because all Swing components listen for Focus events anyway.

Yes this is a hack. Unfortunately we don't know of a better way to make the UI property transient and work correctly on JDK1.1 VMs.


Constructor Summary
private JComponent.EnableSerializationFocusListener()
           
 
Method Summary
 void focusGained(FocusEvent e)
          Invoked when a component gains the keyboard focus.
 void focusLost(FocusEvent e)
          Invoked when a component loses the keyboard focus.
private  void writeObject(ObjectOutputStream s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JComponent.EnableSerializationFocusListener

private JComponent.EnableSerializationFocusListener()
Method Detail

focusGained

public void focusGained(FocusEvent e)
Description copied from interface: FocusListener
Invoked when a component gains the keyboard focus.

Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Description copied from interface: FocusListener
Invoked when a component loses the keyboard focus.

Specified by:
focusLost in interface FocusListener

writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
Throws:
IOException