游标方法在JavaFX中的各个阶段之间不起作用

时间:2015-01-30 21:33:17

标签: webview javafx cursor

我正在尝试制作一个在WebView中加载网页的浏览器,在Stage1中有一个按钮之前,此按钮应在加载网页时设置光标WAITStage2我试过这段代码:

   @FXML
private void tabfirst (ActionEvent ee) throws IOException { // for tha Chooser frame text.

            String hh = text11.getText(); //from Stage1
            Socket socket = new Socket();
    try {

        //open cursor
        panoo.setCursor(Cursor.WAIT); //this component is in Stage1
        que.setCursor(Cursor.WAIT); //this component is in Stage1
        hboxbuttons.setCursor(Cursor.WAIT); //this component is in Stage1
        ancpa.setCursor(Cursor.WAIT); //this component is in Stage2
        //do work
        URL url = new URL (hh);
        url.getContent();
        WebEngine myWebEngine = web1.getEngine();
        myWebEngine.load(url+"");
        //close the window chooser
        Stage stage = new Stage();
          Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
          Scene scene = new Scene(root);
         stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
              @Override public void handle(WindowEvent t) { } });
        //close cursor
         panoo.setCursor(Cursor.DEFAULT);
        que.setCursor(Cursor.DEFAULT);
        hboxbuttons.setCursor(Cursor.DEFAULT);
        ancpa.setCursor(Cursor.DEFAULT);
    }
   catch (IOException e){
       final  Stage stg = new Stage();           
        stg.initModality(Modality.APPLICATION_MODAL);
        stg.initOwner(stg);
        stg.setTitle("Cannot connect to the internet /n Please Verify your connection internet");
        labelno.setText("Cannot connect to the internet...");
        //close chooser
        Stage stage = new Stage();
         Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
         stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
              @Override public void handle(WindowEvent t) { } });

       //set cursor
         ancpa.setCursor(Cursor.DEFAULT);

   } finally{
       try{ socket.close(); } catch (Exception e){ }
       }

}

所以请问我的代码有什么问题,任何人都可以提前帮助我!

0 个答案:

没有答案