1

I have a problem that is driving me crazy, i have a function which controls some electric lockers in my application, i wrote this function to display to the users the lockers that are open and the ones that are close, while he launch this function (through a button) i would show to the user a progress indicator and disable the pane where i have some buttons which represent the lockers (and each of these buttons open the right locker once clicked), but when i click the button to check the lockers it don't disable the HBox and don't set visible the ProgressIndicator, but it execute the part of code which controls the lockers here is the part of the code:

btnCheckSlides.setOnAction((ActionEvent event) ->{
    piControlOnLockers.setVisible(true);//this is the progress indicator
    hBoxButtonSlides.setDisable(true);//and this is the hbox 
    String slideOpen= returnOpenedSlides(drawer,Integer.parseInt(btnCheckSlides.getAccessibleText()));//function which gives me back the number of open lockers


    if(slideOpen.isEmpty()==false){
        String slidesOpen[] = slideOpen.split(";");
        for(int k = 0; k< slidesOpen.length; k++){
            System.out.print(Integer.parseInt(slidesOpen[k]));
            for(int j = 0; j < mainList.get(Integer.parseInt(btnCheckSlides.getAccessibleText())).getChildren().size(); j++){

                if(Integer.parseInt(slidesOpen[k]) == Integer.parseInt(mainList.get(Integer.parseInt(btnCheckSlides.getAccessibleText())).getChildren().get(j).getAccessibleHelp())-1){

                    mainList.get(Integer.parseInt(btnCheckSlides.getAccessibleText())).getChildren().get(j).getStyleClass().add("focus");

                }
            }
        }     
    }                   
    piControlOnLockers.setVisible(false);
    hBoxButtonSlides.setDisable(false);
});

so once the h box is disabled and the pi is visible after the function which controls the lockers they became enable and not visible again

and i tried to comment the code between the initial and the final part like this and it works, i can't understand why a part of code like that is giving me all these problems

btnCheckSlides.setOnAction((ActionEvent event) ->{
    piControlOnLockers.setVisible(true);//this is the progress  indicator
    hBoxButtonSlides.setDisable(true);//and this is the hbox 
    try{

        Thread.sleep(5000); //to see if the box is disabled for 5 secs and the pi is set to visible
    }catch(InterruptedException ex){
        System.out.println(ex.toString());
    }
    piControlOnLockers.setVisible(false);//"hide" the pi again
    hBoxButtonSlides.setDisable(false);//set the box enable again
});

P.S. i comunicato to the lockers through a TCP/IP board, but i think the problem is not there 'cause the function which control of the lockers works perfectly and gives me bad the exact number of the right lockers that are open

Maglioni Lorenzo
  • 358
  • 1
  • 12
  • sorry it was my fault in editing the question – Maglioni Lorenzo Aug 30 '16 at 07:59
  • When you call `Thread.sleep(5000);` you are actually stopping the JavaFX application thread, so the first two statements will not even take place on the GUI as the GUI is not updated immediatly (you set back the values right after the sleep) so on the next GUI refresh tick it will do nothing. – DVarga Aug 30 '16 at 08:03
  • ok, but there it works, it's in the first my problem, in the second(i don't know why) but it works, during the connection to the TCP/IP board i don't use any thread or task – Maglioni Lorenzo Aug 30 '16 at 08:06
  • 1
    See also http://stackoverflow.com/questions/34985943/platform-runlater-issue-delay-execution/34986714#34986714 – Itai Aug 30 '16 at 10:41
  • thank you very much sillyfly that's what i was looking for! – Maglioni Lorenzo Aug 30 '16 at 15:26

0 Answers0