bb.gui
Class GroupLayout2

java.lang.Object
  extended by javax.swing.GroupLayout
      extended by bb.gui.GroupLayout2
All Implemented Interfaces:
LayoutManager, LayoutManager2, Externalizable, Serializable

public class GroupLayout2
extends GroupLayout
implements Externalizable

Subclass of GroupLayout that adds no new functionality except for implementing Externalizable, which is needed because its superclass does not implement Serializable.

This class implements Externalizable with, essentially, empty methods which read and write no data. The sole purpose of these methods is to preempt calls to its superclass during serialization/deserialization, since those calls will fail.

Correct usage of these class in serialization/deserialization is tricky and usually requires some other class to customise deserialization (e.g. to manually restore an equivalent GroupLayout instance). See the source code of LinePanel for one example.

Like typical Java GUI code, this class is not multithread safe: it expects to only be called by EventQueue's dispatch thread. This threading limitation is checked in every public method.

Author:
Brent Boyer
See Also:
Serialized Form

Nested Class Summary
static class GroupLayout2.UnitTest
          See the Overview page of the project's javadocs for a general description of this unit test class.
 
Nested classes/interfaces inherited from class javax.swing.GroupLayout
GroupLayout.Alignment, GroupLayout.Group, GroupLayout.ParallelGroup, GroupLayout.SequentialGroup
 
Field Summary
private static Container hostDummy
          The sole purpose of this method is to provide a host value for the public no-arg constructor.
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.GroupLayout
DEFAULT_SIZE, PREFERRED_SIZE
 
Constructor Summary
GroupLayout2()
          Calls this(hostDummy).
GroupLayout2(Container host)
          Calls super(host).
 
Method Summary
 void readExternal(ObjectInput oi)
          Customizes deserialization.
 void writeExternal(ObjectOutput oo)
          Customizes serialization.
 
Methods inherited from class javax.swing.GroupLayout
addLayoutComponent, addLayoutComponent, createBaselineGroup, createParallelGroup, createParallelGroup, createParallelGroup, createSequentialGroup, getAutoCreateContainerGaps, getAutoCreateGaps, getHonorsVisibility, getLayoutAlignmentX, getLayoutAlignmentY, getLayoutStyle, invalidateLayout, layoutContainer, linkSize, linkSize, maximumLayoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, replace, setAutoCreateContainerGaps, setAutoCreateGaps, setHonorsVisibility, setHonorsVisibility, setHorizontalGroup, setLayoutStyle, setVerticalGroup, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hostDummy

private static final Container hostDummy
The sole purpose of this method is to provide a host value for the public no-arg constructor. It is never used for any other purpose.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

GroupLayout2

public GroupLayout2()
             throws IllegalStateException
Calls this(hostDummy).

This constructor is needed solely because Externalizable requires a public no-arg constructor. Users should never use it.

Throws:
IllegalStateException - if calling thread is not EventQueue's dispatch thread

GroupLayout2

public GroupLayout2(Container host)
             throws IllegalArgumentException,
                    IllegalStateException
Calls super(host).

Parameters:
host - the Container the GroupLayout2 is the LayoutManager for
Throws:
IllegalArgumentException - if host is null
IllegalStateException - if calling thread is not EventQueue's dispatch thread
Method Detail

readExternal

public void readExternal(ObjectInput oi)
                  throws IllegalStateException
Customizes deserialization.

This method does nothing beyond checking the calling thread. Its sole purpose is to keep its unserializable superclass from getting called.

Note that the public no-arg constructor will have been called prior to the deserialization process calling this method. Therefore, after this method returns, this instance has hostDummy as its host forever, regardless of what value it had before serialization; it will always be a worthless instance. So, users of this class must manually restore a clean new instance when deserializing.

Specified by:
readExternal in interface Externalizable
Throws:
IllegalStateException - if calling thread is not EventQueue's dispatch thread

writeExternal

public void writeExternal(ObjectOutput oo)
                   throws IllegalStateException
Customizes serialization.

This method does nothing beyond checking the calling thread. Its sole purpose is to keep its unserializable superclass from getting called.

Specified by:
writeExternal in interface Externalizable
Throws:
IllegalStateException - if calling thread is not EventQueue's dispatch thread