javafx how to get selected row data in table view with checkbox

我与影子孤独终老i 提交于 2019-12-02 13:43:18

Try this on your if:

  if (change.wasUpdated()) {
      String inj = (data.get(change.getFrom()).injured.getValue())?"injuried":"no longer injuried";
      System.out.println(data.get(change.getFrom()).lastName.getValue() + ", " + 
              data.get(change.getFrom()).firstName.getValue() + "  "
              + "changed his status to " + inj);
      System.out.println();  
  }

Note the output as it is will only display if the player is injuried otherwise it will be blank:

Selected row: Gareth Bale (injured)

Selected row: Gareth Bale

To replace it to:

Selected row: Gareth Bale true

Selected row: Gareth Bale false

You will also have to change this function in the player class:

public String toString() {
  return firstName.get() + " " + lastName.get() + (injured.get()?" true":" false");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!