CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.gui.event
Class DefaultDocumentEvent

java.lang.Object
  extended by java.util.EventObject
      extended by ch.randelshofer.gui.event.DefaultDocumentEvent
All Implemented Interfaces:
java.io.Serializable, javax.swing.event.DocumentEvent

public class DefaultDocumentEvent
extends java.util.EventObject
implements javax.swing.event.DocumentEvent

Version:
1.0 2001-10-18
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.event.DocumentEvent
javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent.EventType
 
Field Summary
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
DefaultDocumentEvent(javax.swing.text.Document src, int offs, int len, javax.swing.event.DocumentEvent.EventType type)
          Creates a new DefaultDocumentEvent.
 
Method Summary
 javax.swing.event.DocumentEvent.ElementChange getChange(javax.swing.text.Element elem)
          Gets the change information for the given element.
 javax.swing.text.Document getDocument()
          Gets the document that sourced the change event.
 int getLength()
          Returns the length of the change.
 int getOffset()
          Returns the offset within the document of the start of the change.
 javax.swing.event.DocumentEvent.EventType getType()
          Gets the type of event.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDocumentEvent

public DefaultDocumentEvent(javax.swing.text.Document src,
                            int offs,
                            int len,
                            javax.swing.event.DocumentEvent.EventType type)
Creates a new DefaultDocumentEvent.

Parameters:
src - The Source of the event.
offs - the offset into the document of the change >= 0
len - the length of the change >= 0
type - the type of event DocumentEvent.EventType);
Method Detail

getChange

public javax.swing.event.DocumentEvent.ElementChange getChange(javax.swing.text.Element elem)
Gets the change information for the given element. The change information describes what elements were added and removed and the location. If there were no changes, null is returned.

This method is for observers to discover the structural changes that were made. This means that only elements that existed prior to the mutation (and still exist after the mutatino) need to have ElementChange records. The changes made available need not be recursive.

For example, if the an element is removed from it's parent, this method should report that the parent changed and provide an ElementChange implementation that describes the change to the parent. If the child element removed had children, these elements do not need to be reported as removed.

If an child element is insert into a parent element, the parent element should report a change. If the child element also had elements inserted into it (grandchildren to the parent) these elements need not report change.

Specified by:
getChange in interface javax.swing.event.DocumentEvent
Parameters:
elem - the element
Returns:
the change information, or null if the element was not modified

getDocument

public javax.swing.text.Document getDocument()
Gets the document that sourced the change event.

Specified by:
getDocument in interface javax.swing.event.DocumentEvent
Returns:
the document

getLength

public int getLength()
Returns the length of the change.

Specified by:
getLength in interface javax.swing.event.DocumentEvent
Returns:
the length >= 0

getType

public javax.swing.event.DocumentEvent.EventType getType()
Gets the type of event.

Specified by:
getType in interface javax.swing.event.DocumentEvent
Returns:
the type

getOffset

public int getOffset()
Returns the offset within the document of the start of the change.

Specified by:
getOffset in interface javax.swing.event.DocumentEvent
Returns:
the offset >= 0

(c) Werner Randelshofer.
All rights reserved.