public class ChoiceCallback extends Object implements Callback, Serializable
基础安全服务实例,并通过一个ChoiceCallback到handle一个的方法CallbackHandler ,以显示选项列表并获取选中的选项(S)。
CallbackHandler , Serialized Form
| Constructor and Description |
|---|
ChoiceCallback(String prompt, String[] choices, int defaultChoice, boolean multipleSelectionsAllowed)
构造一个
ChoiceCallback带有提示,选项列表,默认选项和一个布尔值,指定从选项列表中选择多个是否是允许的。
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowMultipleSelections()
获取布尔确定是否允许从
choices列表中选择多个选项。
|
String[] |
getChoices()
获取选择列表。
|
int |
getDefaultChoice()
获取defaultChoice。
|
String |
getPrompt()
获取提示。
|
int[] |
getSelectedIndexes()
获取所选择的选项。
|
void |
setSelectedIndex(int selection)
设置所选择的选项。
|
void |
setSelectedIndexes(int[] selections)
设置所选择的选项。
|
public ChoiceCallback(String prompt, String[] choices, int defaultChoice, boolean multipleSelectionsAllowed)
ChoiceCallback ,其中包含提示,选择列表,默认选项和布尔值,指定是否允许从选项列表中选择多个选项。
prompt - 用于描述选择列表的提示。
choices - 选择列表。
defaultChoice - 显示选项列表时用作默认选择的选项。
该值表示为choices数组的索引。
multipleSelectionsAllowed - 布尔值,指定是否可以从选择列表中进行多个选择。
IllegalArgumentException -如果
prompt为空,如果
prompt具有的长度为0,如果
choices为空,如果
choices具有为0的长度,如果来自任何元件
choices为空,如果从任何元件
choices具有的长度为0,或者如果
defaultChoice确实不属于阵列边界内
choices 。
public String getPrompt()
public String[] getChoices()
public int getDefaultChoice()
choices列表中的索引。
public boolean allowMultipleSelections()
choices列表中选择多个选项。
public void setSelectedIndex(int selection)
selection - 选择表示为
choices列表中的索引。
getSelectedIndexes()
public void setSelectedIndexes(int[] selections)
selections - 表示为
choices列表中的索引的选择。
UnsupportedOperationException - 如果不允许多个选择,由
allowMultipleSelections 。
getSelectedIndexes()
public int[] getSelectedIndexes()
choices列表中的索引。
setSelectedIndexes(int[])
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.