怎样得到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.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询