Terai Atsuhiro 2024-03-30 (土) 23:38:46

http://terai.xrea.jp/swing/rowselection/screenshot.png

tbl.setRowSelectionAllowed(true);
tbl.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
tbl.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
  public void valueChanged(ListSelectionEvent e) {
    if(e.getValueIsAdjusting()) return;
    int sc = tbl.getSelectedRowCount();
    String str;
    if(sc<=0 || sc>1) {
      str = "";
    }else{
      str = getInfo(model.getTest(tbl.getSelectedRow()));
    }
    changeInfoPanel(str);
  }
});