第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

顯示我的網格后無法讓線程休眠

顯示我的網格后無法讓線程休眠

楊魅力 2022-11-30 11:14:23
我有一個網格窗格,我想讓它可見。然后我想暫停程序 2 秒并再次使網格不可見。出于某種原因,網格在我在程序中使用的 thread.sleep 之后變得可見。這一切都發(fā)生在按鈕點擊事件中。我試著繞過 thread.sleep,將它們放在一個新方法中并使用多個睡眠,但沒有任何效果。gameGrid.setVisible(true) gameGrid.setVisible(false) 按鈕事件:public void handleButtonGo(ActionEvent Event) throws IOException {    //On go button press        boolean validation = true;        try {            gameGrid.setVisible(true);            placeShips();                }catch (Exception e){            labelwarning.setText(e.getMessage());   //on error the program will stop trying to place ships and refresh any ships placed so far.            validation = false;            //gameGrid.getChildren().clear();            //BoardSetup();            try {                Thread.sleep(2000);            } catch (InterruptedException e1) {                // TODO Auto-generated catch block                e1.printStackTrace();            }            gameGrid.setVisible(false);        }}網格在 thread.sleep 后顯示一毫秒。
查看完整描述

1 回答

?
慕工程0101907

TA貢獻1887條經驗 獲得超5個贊

使用PauseTransition。

public void handleButtonGo(ActionEvent Event) throws IOException {    //On go button press


        boolean validation = true;

        try {


            gameGrid.setVisible(true);

            placeShips();        


        }catch (Exception e){


            labelwarning.setText(e.getMessage());   //on error the program will stop trying to place ships and refresh any ships placed so far.

            validation = false;

            //gameGrid.getChildren().clear();

            //BoardSetup();

            PauseTransition wait = new PauseTransition(Duration.seconds(2));

            wait.setOnFinished((e) -> {

                /*YOUR METHOD*/      

                gameGrid.setVisible(false);

            });

            wait.play();        


        }

}


查看完整回答
反對 回復 2022-11-30
  • 1 回答
  • 0 關注
  • 88 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號