I got a checkBox on my javafx table in every single row. It appears on the user inferface. However, it does not do anything when I click on it. My table load the data of "webPage" type. Here is my "webPage" class:
public class webPage {
private StringProperty navBar;
private StringProperty fileName;
private StringProperty script;
private BooleanProperty use;
private CheckBox ToBeExported;
public webPage(String nav, String fn, String s){
navBar = new SimpleStringProperty(nav);
fileName = new SimpleStringProperty(fn);
script = new SimpleStringProperty(s);
ToBeExported = new CheckBox();
use = new SimpleBooleanProperty(true);
}
public BooleanProperty getUse(){
return use;
}
public void setUse(boolean isUse){
use.set(isUse);
}
public boolean getUseBoolean(){
return use.get();
}
public String getNavBar(){
return navBar.get();
}
public String getFileName(){
return fileName.get();
}
public String getScript(){
return script.get();
}
/**
* @param navBar the navBar to set
*/
public void setNavBar(StringProperty navBar) {
this.navBar = navBar;
}
/**
* @param fileName the fileName to set
*/
public void setFileName(StringProperty fileName) {
this.fileName = fileName;
}
/**
* @param script the script to set
*/
public void setScript(StringProperty script) {
this.script = script;
}
public StringProperty navBarProperty(){
return navBar;
}
public StringProperty fileNameProperty(){
return fileName;
}
public StringProperty scriptProperty(){
return script;
}
}
Then, here is my the portion of my code where I put the checkBox into my javaFX table, and the table and column are already declared in the constructor. select.setCellFactory(column -> new CheckBoxTableCell());
select.setCellValueFactory(new Callback<CellDataFeatures<webPage,Boolean>,ObservableValue<Boolean>>()
{
//This callback tell the cell how to bind the data model 'Registered' property to
//the cell, itself.
@Override
public ObservableValue<Boolean> call(CellDataFeatures<webPage, Boolean> param)
{
return param.getValue().getUse();
}
});
Aucun commentaire:
Enregistrer un commentaire