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

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

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