APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class DefaultSingleSelectionModel

extends Object
implements SingleSelectionModel, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.SingleSelectionModel
Annotations
@SuppressWarnings:serial
Imports
javax.swing.event.*, java.io.Serializable, java.util.EventListener

A generic implementation of SingleSelectionModel.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
Dave Moore
Since
1.2

Field Summary

Modifier and TypeField and Description
protected transient ChangeEvent
changeEvent

Only one ModelChangeEvent is needed per model instance since the event's only (read-only) state is the source property.

private int
protected EventListenerList
listenerList

The collection of registered listeners

Constructor Summary

AccessConstructor and Description
public
DefaultSingleSelectionModel()

Constructs a DefaultSingleSelectionModel.

Method Summary

Modifier and TypeMethod and Description
public void
addChangeListener(ChangeListener l)

Implements javax.swing.SingleSelectionModel.addChangeListener.

Adds a ChangeListener to the button.

public void
clearSelection()

Implements javax.swing.SingleSelectionModel.clearSelection.

Clears the selection (to -1).

protected void
fireStateChanged()

Notifies all listeners that have registered interest for notification on this event type.

public ChangeListener[]

Returns:

all of this model's ChangeListeners or an empty array if no change listeners are currently registered
getChangeListeners
()

Returns an array of all the change listeners registered on this DefaultSingleSelectionModel.

public <
the type of EventListener class being requested
T extends EventListener
>
T[]

Returns:

an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added
getListeners
(Class<T>
the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
listenerType
)

Returns an array of all the objects currently registered as FooListeners upon this model.

public int
getSelectedIndex()

Implements javax.swing.SingleSelectionModel.getSelectedIndex.

Returns the model's selection.

public boolean
isSelected()

Implements javax.swing.SingleSelectionModel.isSelected.

Returns true if the selection model currently has a selected value.

public void
removeChangeListener(ChangeListener l)

Implements javax.swing.SingleSelectionModel.removeChangeListener.

Removes a ChangeListener from the button.

public void
setSelectedIndex(int index)

Implements javax.swing.SingleSelectionModel.setSelectedIndex.

Sets the model's selected index to index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changeEventback to summary
protected transient ChangeEvent changeEvent

Only one ModelChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

indexback to summary
private int index
listenerListback to summary
protected EventListenerList listenerList

The collection of registered listeners

Constructor Detail

DefaultSingleSelectionModelback to summary
public DefaultSingleSelectionModel()

Constructs a DefaultSingleSelectionModel.

Method Detail

addChangeListenerback to summary
public void addChangeListener(ChangeListener l)

Implements javax.swing.SingleSelectionModel.addChangeListener.

Adds a ChangeListener to the button.

clearSelectionback to summary
public void clearSelection()

Implements javax.swing.SingleSelectionModel.clearSelection.

Doc from javax.swing.SingleSelectionModel.clearSelection.

Clears the selection (to -1).

fireStateChangedback to summary
protected void fireStateChanged()

Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

See Also
EventListenerList
getChangeListenersback to summary
public ChangeListener[] getChangeListeners()

Returns an array of all the change listeners registered on this DefaultSingleSelectionModel.

Returns:ChangeListener[]

all of this model's ChangeListeners or an empty array if no change listeners are currently registered

Since
1.4
See Also
addChangeListener, removeChangeListener
getListenersback to summary
public <T extends EventListener> T[] getListeners(Class<T> listenerType)

Returns an array of all the objects currently registered as FooListeners upon this model. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultSingleSelectionModel instance m for its change listeners with the following code:

ChangeListener[] cls = (ChangeListener[])(m.getListeners(ChangeListener.class));
If no such listeners exist, this method returns an empty array.
Parameters
<T>
the type of EventListener class being requested
listenerType:Class<T>

the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener

Returns:T[]

an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added

Exceptions
ClassCastException:
if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since
1.3
See Also
getChangeListeners
getSelectedIndexback to summary
public int getSelectedIndex()

Implements javax.swing.SingleSelectionModel.getSelectedIndex.

Doc from javax.swing.SingleSelectionModel.getSelectedIndex.

Returns the model's selection.

isSelectedback to summary
public boolean isSelected()

Implements javax.swing.SingleSelectionModel.isSelected.

Doc from javax.swing.SingleSelectionModel.isSelected.

Returns true if the selection model currently has a selected value.

removeChangeListenerback to summary
public void removeChangeListener(ChangeListener l)

Implements javax.swing.SingleSelectionModel.removeChangeListener.

Removes a ChangeListener from the button.

setSelectedIndexback to summary
public void setSelectedIndex(int index)

Implements javax.swing.SingleSelectionModel.setSelectedIndex.

Doc from javax.swing.SingleSelectionModel.setSelectedIndex.

Sets the model's selected index to index. Notifies any listeners if the model changes