怎样得到Jlist或者说DefaultListModel已选择的项?
我在两个JList中分别添加了两个DefaultListModel,里面的选项是String类型的,怎样才能得到选择项的值?...
我在两个JList中分别添加了两个DefaultListModel,里面的选项是String类型的,怎样才能得到选择项的值?
展开
2个回答
展开全部
通过JList,有单选或多选的两个情况
int getSelectedIndex()
Returns the smallest selected cell index; the selection when only
a single item is selected in the list.
int[] getSelectedIndices()
Returns an array of all of the selected indices, in increasing
order.
Object getSelectedValue()
Returns the value for the smallest selected cell index;
the selected value when only a single item is selected in the
list.
Object[] getSelectedValues()
Returns an array of all the selected values, in increasing order based on their indices in the list.
int getSelectedIndex()
Returns the smallest selected cell index; the selection when only
a single item is selected in the list.
int[] getSelectedIndices()
Returns an array of all of the selected indices, in increasing
order.
Object getSelectedValue()
Returns the value for the smallest selected cell index;
the selected value when only a single item is selected in the
list.
Object[] getSelectedValues()
Returns an array of all the selected values, in increasing order based on their indices in the list.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询