public class ListModelArray<E> extends AbstractListModel<E> implements Sortable<E>, java.io.Serializable
This is the ListModel
as an Object array to be used with Listbox
.
Change the contents of this model as an Object array would cause the associated Listbox to
change accordingly.
The class implements the Selectable
interface, updating
the selection status after sorted. (since 6.0.0)
ListModel
,
ListModelList
,
ListModelMap
,
Serialized FormAbstractListModel.DefaultSelectionControl<E>
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object[] |
_array |
_selection
INTERNAL_EVENT
Constructor and Description |
---|
ListModelArray(E[] array)
Constructor.
|
ListModelArray(E[] array,
boolean live)
Constructor
|
ListModelArray(int size)
Constructor.
|
ListModelArray(java.util.List<? extends E> list)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSelection(E obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.addToSelection(E) . |
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object o) |
protected void |
fireSelectionEvent(E e)
Selectable's implementor use only.
|
E |
get(int index)
Get the value of this ListModelArray at specified index.
|
E |
getElementAt(int j)
Returns the value at the specified index.
|
java.lang.Object[] |
getInnerArray()
Get the inner real Object[].
|
int |
getSize()
Returns the length of the list.
|
java.lang.String |
getSortDirection(java.util.Comparator<E> cmpr)
Returns the sort direction of this model for the given comparator.
|
int |
hashCode() |
int |
indexOf(java.lang.Object elm)
Returns the index of the specified element.
|
boolean |
notifyChange(E element)
Notifies a change of the same element to trigger an event of
ListDataEvent.CONTENTS_CHANGED . |
void |
removeSelection(java.lang.Object obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.removeFromSelection(java.lang.Object) . |
void |
set(int index,
E value)
Change content of the Array at specified index.
|
void |
sort(java.util.Comparator<E> cmpr,
boolean ascending)
Sorts the data.
|
java.lang.String |
toString() |
addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getPageCount, getPageSize, getSelection, getSelectionControl, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelection
public ListModelArray(E[] array, boolean live)
array
- the array to representlive
- whether to have a 'live' ListModel
on top of
the specified array.
If false, the content of the specified array is copied.
If true, this object is a 'facade' of the specified array,
i.e., when you add or remove items from this ListModelArray
,
the inner "live" array would be changed accordingly.
However, it is not a good idea to modify array
if it is passed to this method with live is true,
since Listbox
is not smart enough to handle it.
Instead, modify it thru this object.public ListModelArray(E[] array)
Notice that if the data is static or not shared, it is better to
use ListModelArray(array, true)
instead, since
making a copy is slower.
public ListModelArray(int size)
size
- the array size.public ListModelArray(java.util.List<? extends E> list)
public E get(int index)
index
- the array index to be get value.public void set(int index, E value)
index
- the array index to be set the new value.public java.lang.Object[] getInnerArray()
public int indexOf(java.lang.Object elm)
public boolean notifyChange(E element)
ListDataEvent.CONTENTS_CHANGED
.element
- public int getSize()
ListModel
public E getElementAt(int j)
ListModel
getElementAt
in interface ListModel<E>
public void sort(java.util.Comparator<E> cmpr, boolean ascending)
public java.lang.String getSortDirection(java.util.Comparator<E> cmpr)
Sortable
Default: "natural".
getSortDirection
in interface Sortable<E>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in class AbstractListModel<E>
protected void fireSelectionEvent(E e)
AbstractListModel
Fires a selection event for component to scroll into view. The override
subclass must put the index0 of AbstractListModel.fireEvent(int, int, int)
as
the view index to scroll. By default, the value -1 is assumed which means
no scroll into view.
The method is invoked when both methods are invoked. AbstractListModel.addToSelection(Object)
and AbstractListModel.setSelection(Collection)
.
fireSelectionEvent
in class AbstractListModel<E>
e
- selected object.public void addSelection(E obj)
AbstractListModel.addToSelection(E)
.public void removeSelection(java.lang.Object obj)
AbstractListModel.removeFromSelection(java.lang.Object)
.Copyright © 2005-2021 Potix Corporation. All Rights Reserved.