+ -
当前位置:首页 → 问答吧 → JList怎么没有getSelectValue(),那怎么获取鼠标点击的选项

JList怎么没有getSelectValue(),那怎么获取鼠标点击的选项

时间:2011-12-04

来源:互联网

如题

作者: zhengruowen   发布时间: 2011-12-04

JList. addListSelectionListener();

下面是ListSelectionListener要实现的方法
public void valueChanged(ListSelectionEvent e) {
  if (e.getValueIsAdjusting() == false) {

  if (list.getSelectedIndex() == -1) {
  //No selection, disable fire button.
  fireButton.setEnabled(false);

  } else {
  //Selection, enable the fire button.
  fireButton.setEnabled(true);
  }
  }
}

作者: Inhibitory   发布时间: 2011-12-04

那怎么获取JList选中的文本呢?

作者: zhengruowen   发布时间: 2011-12-04