求助,ListSelectionModel.SINGLE
答案:2 悬赏:60 手机版
解决时间 2021-03-09 05:26
- 提问者网友:孤凫
- 2021-03-09 01:30
求助,ListSelectionModel.SINGLE
最佳答案
- 五星知识达人网友:走死在岁月里
- 2021-03-09 03:08
1、你怎么知道e.getSource()得到的值就是list1或者list2,那道就因为if(e.getSource()==list1)这个,==只能说明他们两个在内存中的地址是一样的,这是源码的方法定义public java.lang.Object getSource();看到没有,他返回的是一个object,所以要强制类型转换。
2、Object listValue=((JList)e.getSource()).getSelectedValue();
String seleName=listValue.toString(); listValue是object类型,当然要toString
3、getSelectedIndices()返回的就是一个整型数组,
int[] getSelectedIndices()
Returns an array of all of the selected indices, in increasing order. 这是官方api
4、
void setVisibleRowCount(int visibleRowCount)
Sets the visibleRowCount property, which has different meanings depending on the layout orientation: For a VERTICAL layout orientation, this sets the preferred number of rows to display without requiring scrolling; for other orientations, it affects the wrapping of cells.
官方解释
2、Object listValue=((JList)e.getSource()).getSelectedValue();
String seleName=listValue.toString(); listValue是object类型,当然要toString
3、getSelectedIndices()返回的就是一个整型数组,
int[] getSelectedIndices()
Returns an array of all of the selected indices, in increasing order. 这是官方api
4、
void setVisibleRowCount(int visibleRowCount)
Sets the visibleRowCount property, which has different meanings depending on the layout orientation: For a VERTICAL layout orientation, this sets the preferred number of rows to display without requiring scrolling; for other orientations, it affects the wrapping of cells.
官方解释
全部回答
- 1楼网友:举杯邀酒敬孤独
- 2021-03-09 04:20
家家有本难念的经。。。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯