站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ChangeableLookProvider (Looks) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.looks/2 1.12

org.netbeans.spi.looks
Interface ChangeableLookProvider


public interface ChangeableLookProvider

Interface for finding a Looks for given represented object. To create a LookSelector implement this interface and call Selectors.selector( ChangeableLookProvider ). LookSelectors created from this interface are allowed to change the content. To do so you have to implement the addChangeListener(javax.swing.event.ChangeListener) method and fire the changes on the registered listener. Typical implementation of the method would look like:

if ( this.listener != null ) { throw new TooManyListenersException(); } else { this.listener = listener; }

and fire method would look like:

listener.stateChanged( new ChangeEvent( this ) );

Notice that it is usually not necessary to create a list of listeners and rather throw TooManyListeners exception if there would be more than one listener registered. The reason is that reusing one instance of ChangeableLookProvider would result in two LookSelectors with the same behavior i.e. you may rather want to reuse the LookSelector than the Provider.

See Also:
for creating LooksSelectors which have fixed content

Method Summary
 void addChangeListener(ChangeListener listener)
          Registers listener for changes in the Provider's content.
 Object getKeyForObject(Object representedObject)
          Returns key for given object.
 Enumeration getLooksForKey(Object key)
          Finds all suitable Looks for given key.
 

Method Detail

getLooksForKey

Enumeration getLooksForKey(Object key)
Finds all suitable Looks for given key. The key for a representedObject is obtained by call to the (@link #getKey} method.

Parameters:
key - The key we want to find available looks for.
Returns:
Enumeration of available Looks

getKeyForObject

Object getKeyForObject(Object representedObject)
Returns key for given object. Make sure you return the same key for given object during whole lifecycle of the LookSelector. This means that changes in the content are changes in the enumerations of Looks for given key not a change in a key which is returned for given object. (It also means that it is not good idea to base the implementation of this method on an attribute of an object which can change. Changes in representation of such attributes should generally be handled by Looks rather than LookSelectors/Providers)

Parameters:
representedObject - The represented object we want to find key for.
Returns:
Key for given represented object. Returning null instead of a key will result in returning empty Enumeration from the LookSelector.

addChangeListener

void addChangeListener(ChangeListener listener)
                       throws TooManyListenersException
Registers listener for changes in the Provider's content. Call stateChanged on the registered listener to notify it about change in the Look enumerations returned for keys.

Parameters:
listener - The listenet which should be notified when change in the Provider's content occurs.
Throws:
TooManyListenersException - May be thrown when more than one listener is registered.
See Also:
for info about correct behavior of the Provider

org.netbeans.modules.looks/2 1.12

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.