|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
public interface ListSelectionModel
此介面表示任何元件的當前選擇狀態,該元件顯示一個具有穩定索引的值列表。該選擇被建模為一組區間,每個區間表示一個選定列表元素的連續範圍。修改該組選定區間的方法都採用一對索引:index0 和 index1,這對索引表示一個閉區間,即該區間同時包括 index0 和 index1。
DefaultListSelectionModel| 欄位摘要 | |
|---|---|
static int |
MULTIPLE_INTERVAL_SELECTION
selectionMode 屬性的值:一次選擇一個或多個連續的索引範圍。 |
static int |
SINGLE_INTERVAL_SELECTION
selectionMode 屬性的值:一次選擇一個連續的索引範圍。 |
static int |
SINGLE_SELECTION
selectionMode 屬性的值:一次選擇一個列表索引。 |
| 方法摘要 | |
|---|---|
void |
addListSelectionListener(ListSelectionListener x)
將偵聽器添加到每次在選擇發生更改時都得到通知的列表。 |
void |
addSelectionInterval(int index0,
int index1)
將選擇更改為當前選擇與 index0 和 index1 之間(包括兩者)索引的並集。 |
void |
clearSelection()
將該選擇更改為空集。 |
int |
getAnchorSelectionIndex()
從對 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近調用中返回第一個索引參數。 |
int |
getLeadSelectionIndex()
從對 setSelectionInterval()、addSelectionInterval() 或 removeSelectionInterval() 的最近調用中返回第二個索引參數。 |
int |
getMaxSelectionIndex()
返回最後選擇的索引,如果選擇為空,則返回 -1。 |
int |
getMinSelectionIndex()
返回第一個選擇的索引,如果選擇為空,則返回 -1。 |
int |
getSelectionMode()
返回當前選擇網要。 |
boolean |
getValueIsAdjusting()
如果選擇在進行一系列更改,則返回 true。 |
void |
insertIndexInterval(int index,
int length,
boolean before)
在 index 之前/之後開始插入 length 個索引。 |
boolean |
isSelectedIndex(int index)
如果選擇了指定的索引,則返回 true。 |
boolean |
isSelectionEmpty()
如果沒有選擇索引,則返回 true。 |
void |
removeIndexInterval(int index0,
int index1)
從選擇模型中移除區間 index0、index1(包括)中的索引。 |
void |
removeListSelectionListener(ListSelectionListener x)
將偵聽器從每次在選擇發生更改時都得到通知的列表中移除。 |
void |
removeSelectionInterval(int index0,
int index1)
將選擇更改為當前選擇與 index0 和 index1 之間(包括兩者)索引的差集。 |
void |
setAnchorSelectionIndex(int index)
設置 anchor 選擇索引。 |
void |
setLeadSelectionIndex(int index)
設置 lead 選擇索引。 |
void |
setSelectionInterval(int index0,
int index1)
將選擇更改為在 index0 和 index1 之間(包括兩者)。 |
void |
setSelectionMode(int selectionMode)
設置選擇網要。 |
void |
setValueIsAdjusting(boolean valueIsAdjusting)
設置 valueIsAdjusting 屬性,指示即將進行的選擇更改是否應該被視為單個更改的一部分。 |
| 欄位詳細資訊 |
|---|
static final int SINGLE_SELECTION
setSelectionMode(int),
常數欄位值static final int SINGLE_INTERVAL_SELECTION
setSelectionMode(int),
常數欄位值static final int MULTIPLE_INTERVAL_SELECTION
setSelectionMode(int),
常數欄位值| 方法詳細資訊 |
|---|
void setSelectionInterval(int index0,
int index1)
index0 和 index1 之間(包括兩者)。index0 不必小於等於 index1。
在 SINGLE_SELECTION 選擇網要中,只使用第二個索引。
如果這表示對當前選擇的更改,則通知每個 ListSelectionListener 該更改。
index0 - 區間的一端。index1 - 區間的另一端addListSelectionListener(javax.swing.event.ListSelectionListener)
void addSelectionInterval(int index0,
int index1)
index0 和 index1 之間(包括兩者)索引的並集。index0 不必小於等於 index1。
在 SINGLE_SELECTION 選擇網要中,這等效於調用 setSelectionInterval,並且只使用第二個索引。在 SINGLE_INTERVAL_SELECTION 選擇網要中,此方法行為類似於 setSelectionInterval,除非給定區間緊接現有選擇或與現有選擇重疊從而可用於增大該選擇。
如果這表示對當前選擇的更改,則通知每個 ListSelectionListener 該更改。
index0 - 區間的一端。index1 - 區間的另一端addListSelectionListener(javax.swing.event.ListSelectionListener),
setSelectionInterval(int, int)
void removeSelectionInterval(int index0,
int index1)
index0 和 index1 之間(包括兩者)索引的差集。index0 不必小於等於 index1。
在 SINGLE_INTERVAL_SELECTION 選擇網要中,如果移除操作會產生兩個不相交的選擇,那麼移除操作將延伸到選擇的較大端。例如,如果選擇是 0-10,提供的索引是 5,6(按任意順序),則所得選擇是 0-4。
如果這表示對當前選擇的更改,則通知每個 ListSelectionListener 該更改。
index0 - 區間的一端。index1 - 區間的另一端addListSelectionListener(javax.swing.event.ListSelectionListener)int getMinSelectionIndex()
int getMaxSelectionIndex()
boolean isSelectedIndex(int index)
int getAnchorSelectionIndex()
getLeadSelectionIndex(),
setSelectionInterval(int, int),
addSelectionInterval(int, int)void setAnchorSelectionIndex(int index)
getAnchorSelectionIndex()int getLeadSelectionIndex()
getAnchorSelectionIndex(),
setSelectionInterval(int, int),
addSelectionInterval(int, int)void setLeadSelectionIndex(int index)
getLeadSelectionIndex()void clearSelection()
addListSelectionListener(javax.swing.event.ListSelectionListener)boolean isSelectionEmpty()
void insertIndexInterval(int index,
int length,
boolean before)
void removeIndexInterval(int index0,
int index1)
void setValueIsAdjusting(boolean valueIsAdjusting)
valueIsAdjusting 屬性,指示即將進行的選擇更改是否應該被視為單個更改的一部分。此屬性的值用於初始化產生 ListSelectionEvent 的 valueIsAdjusting 屬性。
例如,如果選擇被更新以回應一個使用者的拖動,那麼在拖動開始時,此屬性被設置為 true;在拖動結束時被設置為 false。在拖動期間,偵聽器接收 valueIsAdjusting 屬性設置為 true 的事件。在拖動的最後,當更改終止時,偵聽器接收一個值設置為 false 的事件。如果只在更改已終止時希望更新,則偵聽器可以使用此網要。
將此屬性設置為 true 將開始一系列將被視為單個更改一部分的更改。當該屬性更改回 false 時,發送一個表現整個選擇更改特徵的事件(如果有),該事件的 valueIsAdjusting 屬性設置為 false。
valueIsAdjusting - 屬性的新值getValueIsAdjusting(),
ListSelectionEvent.getValueIsAdjusting()boolean getValueIsAdjusting()
true。
setValueIsAdjusting(boolean)void setSelectionMode(int selectionMode)
ListSelectionModel.SINGLE_SELECTION - 一次只能選擇一個列表索引。在此網要中,setSelectionInterval 和 addSelectionInterval 是等效的,兩者都使用第二個參數(「lead」)所表示的索引來替換當前選擇。
ListSelectionModel.SINGLE_INTERVAL_SELECTION - 一次只能選擇一個連續索引區間。在此網要中,addSelectionInterval 行為類似於 setSelectionInterval(替換當前選擇),除非給定區間緊接現有選擇或與現有選擇重疊從而可用於增大該選擇。
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION - 在此網要中,對選擇內容無任何限制。
IllegalArgumentException - 如果選擇網要不是允許的網要之一getSelectionMode()int getSelectionMode()
setSelectionMode(int)void addListSelectionListener(ListSelectionListener x)
x - ListSelectionListenerremoveListSelectionListener(javax.swing.event.ListSelectionListener),
setSelectionInterval(int, int),
addSelectionInterval(int, int),
removeSelectionInterval(int, int),
clearSelection(),
insertIndexInterval(int, int, boolean),
removeIndexInterval(int, int)void removeListSelectionListener(ListSelectionListener x)
x - ListSelectionListeneraddListSelectionListener(javax.swing.event.ListSelectionListener)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。