public class ChoiceCallback extends Object implements Callback, Serializable
基本的安全服务,通过ChoiceCallback
实例化的CallbackHandler
的handle
方法显示一个选项列表和检索选择(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
任何元素为null,如果从
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.