net.sf.jguiraffe.gui.platform.swing.builder.components
Class SwingComponentHandler

java.lang.Object
  extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComponentHandler
All Implemented Interfaces:
ComponentHandler, SwingEventSource
Direct Known Subclasses:
SwingButtonHandler, SwingListModelHandler, SwingProgressBarHandler, SwingStaticTextComponentHandler, SwingTabbedPaneHandler, SwingTableComponentHandler, SwingTextHandler

abstract class SwingComponentHandler
extends java.lang.Object
implements ComponentHandler, SwingEventSource

A base class for all ComponentHandler classes of the Swing implementation.

This base class maintains a JComponent reference and provides some common functionality, especially related to event handling.

Version:
$Id: SwingComponentHandler.java 67 2007-06-09 19:11:01Z oheger $
Author:
Oliver Heger

Constructor Summary
protected SwingComponentHandler(javax.swing.JComponent comp)
          Creates a new instance of SwingComponentHandler and sets the component to manage.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds an action listener at the managed component.
 void addChangeListener(ChangeListener l)
          Adds a change listener at the managed component.
 void addFocusListener(java.awt.event.FocusListener l)
          Registers a focus listener at the managed component.
protected  void fireChangeEvent(java.lang.Object event)
          Fires a change event to the registered change listeners.
 java.lang.Object getComponent()
          Returns a reference to the managed component.
 javax.swing.JComponent getJComponent()
          Returns a reference to the managed Swing component.
 java.lang.Object getOuterComponent()
          Returns the outer most component.
 boolean isEnabled()
          Checks whether the managed component is enabled.
protected  void registerChangeListener()
          Registers this component handler as a change listener at the managed component.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes an action listener from the managed component.
 void removeChangeListener(ChangeListener l)
          Removes a change listener from this component.
 void removeFocusListener(java.awt.event.FocusListener l)
          Removes the specified focus listener from this component.
 void setEnabled(boolean f)
          Sets the enabled flag of the managed component.
protected  void unregisterChangeListener()
          Unregisters this component as change listener from the managed component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jguiraffe.gui.forms.ComponentHandler
getData, getType, setData
 

Constructor Detail

SwingComponentHandler

protected SwingComponentHandler(javax.swing.JComponent comp)
Creates a new instance of SwingComponentHandler and sets the component to manage.

Parameters:
comp - the associated component
Method Detail

getJComponent

public javax.swing.JComponent getJComponent()
Returns a reference to the managed Swing component.

Returns:
the Swing component

getComponent

public java.lang.Object getComponent()
Returns a reference to the managed component.

Specified by:
getComponent in interface ComponentHandler
Returns:
the component

getOuterComponent

public java.lang.Object getOuterComponent()
Returns the outer most component. This implementation returns the same component as getComponent().

Specified by:
getOuterComponent in interface ComponentHandler
Returns:
the outer most component

isEnabled

public boolean isEnabled()
Checks whether the managed component is enabled.

Specified by:
isEnabled in interface ComponentHandler
Returns:
a flag whether this component is enabled

setEnabled

public void setEnabled(boolean f)
Sets the enabled flag of the managed component.

Specified by:
setEnabled in interface ComponentHandler
Parameters:
f - the value of the enabled flag

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds an action listener at the managed component. This implementation throws an UnsupportedOperationException exception. (Many components do not support action listeners.)

Specified by:
addActionListener in interface SwingEventSource
Parameters:
l - the listener to register

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes an action listener from the managed component. This implementation throws an UnsupportedOperationException exception. (Many components do not support action listeners.)

Specified by:
removeActionListener in interface SwingEventSource
Parameters:
l - the listener to remove

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a change listener at the managed component. This implementation supports only a single change listener (which should not be a limitation because FormEventManager will do the multiplexing). Because there is no generic change listener in Swing registerChangeListener() will be invoked for doing the actual registration.

Specified by:
addChangeListener in interface SwingEventSource
Parameters:
l - the listener to register

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a change listener from this component. With this method the change listener that has been registered using addChangeListener() can be removed again. If the passed in listener is different from the registered listener, this operation will have no effect.

Specified by:
removeChangeListener in interface SwingEventSource
Parameters:
l - the listener to be removed
See Also:
addChangeListener(ChangeListener)

addFocusListener

public void addFocusListener(java.awt.event.FocusListener l)
Registers a focus listener at the managed component. This implementation is fully functional.

Specified by:
addFocusListener in interface SwingEventSource
Parameters:
l - the listener to register

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener l)
Removes the specified focus listener from this component.

Specified by:
removeFocusListener in interface SwingEventSource
Parameters:
l - the listener to be removed

registerChangeListener

protected void registerChangeListener()
Registers this component handler as a change listener at the managed component. This method is called when the first change listener is added. A derived class which supports change listeners must override it by registering the correct listener type. In the listener's event handling method the fireEvent() method should be called. This implementation throws an UnsupportedOperationException exception.


unregisterChangeListener

protected void unregisterChangeListener()
Unregisters this component as change listener from the managed component. This method is invoked by removeChangeListener(). This base implementation throws an UnsupportedOperationException exception.

See Also:
registerChangeListener()

fireChangeEvent

protected void fireChangeEvent(java.lang.Object event)
Fires a change event to the registered change listeners.

Parameters:
event - the event


Copyright 2007 null. All Rights Reserved.