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

后端 未结 1 1317
醉话见心
醉话见心 2021-01-29 16:00

In this project I can\'t get whether the Checkbox data was selected or not in the console output.

My code:

import java.util.Arrays;
import java.util.Iter         


        
1条回答
  •  无人及你
    2021-01-29 16:56

    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");
    }
    

    0 讨论(0)
提交回复
热议问题