0
Good afternoon, you guys!
I am studying javafx and I am creating a simple application, I was doing well until I came across the following problem: I have a model class 'User' that may or may not have administrator privilege, the problem occurs when I list users in a table view I would like to have "YES" or "NO" appear in the corresponding field column instead of true/false. I tried by toString() model class but it didn’t work, follows the table image:
my code that loads the table:
public void carregarTabela(List<Usuario> usuarios) {
colUser.setCellValueFactory(new PropertyValueFactory<Usuario, String>("user"));
colSenha.setCellValueFactory(new PropertyValueFactory<Usuario, String>("senha"));
colAdm.setCellValueFactory(new PropertyValueFactory<Usuario,String >("admin"));
tabelaUsuarios.getItems().setAll(usuarios);
}
Below the toString of the model class:
@Override
public String toString() {
String admin = null;
if(isAdmin()) {
admin="SIM";
}admin="NÃO";
return "Usuario [user=" + user + ", senha=" + senha + ", admin=" + admin + "]";
}
From now on I thank anyone who can help me!
Cassio, thank you so much! That’s just what I needed!
– Marcio