java - javafx how to get selected data from tableview using FXML -
i working on project want selected data of tableview using fxml.
i have codes no-fxml unable use fxml.
code:
public class person1 { private final stringproperty firstname = new simplestringproperty(""); private final stringproperty surname = new simplestringproperty(""); private final stringproperty goodnameof1 = new simplestringproperty(""); public person1(string firstname) { setfirstname(firstname); } public string getfirstname() { return firstname.get(); } public void setfirstname(string name) { this.firstname.set(name); } public stringproperty firstnameproperty() { return firstname; } public string getsurname() { return surname.get(); } public void setsurname(string name) { surname.set(name); } public stringproperty surnameproperty() { return surname; } public string getgoodnameof1() { return goodnameof1.get(); } public void setgoodnameof1(string name) { goodnameof1.set(name); } }
testcontroller:
public class testcontroller implements initializable { /** * initializes controller class. */ @override public void initialize(url url, resourcebundle rb) { } @fxml private tableview<person1> table; @fxml void add(actionevent event) { table.getitems().add(new person1("dsdsd")); } }
now want know code selected data tableview
please me.
thank you.
if want selected row index, use
table.getselectionmodel().getselectedindex();
Comments
Post a Comment