jeudi 22 septembre 2016

javaFX CheckBox isSelected from other class

public class controller implements Initializable{

@FXML CheckBox chBox;

@Override
public void initialize(URL location, ResourceBundle resources) {

......


  }end of initialize
}//end of class

i set up the check box in controller class and i made new editting cell class to edit tableview only if checkbox is selected.

    public class editingCell {

    public void startEdit(){

    ...
    }


    ...

    //i made checkbox status method
    public boolean checkBoxStatus(){
  try{
   Parent parent = FXMLLoader.load(getClass().getResource("root.fxml"));
    CheckBox cBox = parent.lookup("#chBox")
        if(cBox.isSelected){
             return true;
             }
      }catch(Exception e){}


       return false;

    }

    }

but cBox.isSelected always return false even if box is checked. how can i solve this problem??




Aucun commentaire:

Enregistrer un commentaire