久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='Z7OGq'></tfoot>

<small id='Z7OGq'></small><noframes id='Z7OGq'>

  • <i id='Z7OGq'><tr id='Z7OGq'><dt id='Z7OGq'><q id='Z7OGq'><span id='Z7OGq'><b id='Z7OGq'><form id='Z7OGq'><ins id='Z7OGq'></ins><ul id='Z7OGq'></ul><sub id='Z7OGq'></sub></form><legend id='Z7OGq'></legend><bdo id='Z7OGq'><pre id='Z7OGq'><center id='Z7OGq'></center></pre></bdo></b><th id='Z7OGq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Z7OGq'><tfoot id='Z7OGq'></tfoot><dl id='Z7OGq'><fieldset id='Z7OGq'></fieldset></dl></div>

      <bdo id='Z7OGq'></bdo><ul id='Z7OGq'></ul>
  • <legend id='Z7OGq'><style id='Z7OGq'><dir id='Z7OGq'><q id='Z7OGq'></q></dir></style></legend>

        使用 JavaFX 在任何地方處理鼠標事件

        Handle mouse event anywhere with JavaFX(使用 JavaFX 在任何地方處理鼠標事件)
        <tfoot id='W9dIV'></tfoot>
      1. <legend id='W9dIV'><style id='W9dIV'><dir id='W9dIV'><q id='W9dIV'></q></dir></style></legend>
        • <bdo id='W9dIV'></bdo><ul id='W9dIV'></ul>

              <tbody id='W9dIV'></tbody>
            1. <small id='W9dIV'></small><noframes id='W9dIV'>

              <i id='W9dIV'><tr id='W9dIV'><dt id='W9dIV'><q id='W9dIV'><span id='W9dIV'><b id='W9dIV'><form id='W9dIV'><ins id='W9dIV'></ins><ul id='W9dIV'></ul><sub id='W9dIV'></sub></form><legend id='W9dIV'></legend><bdo id='W9dIV'><pre id='W9dIV'><center id='W9dIV'></center></pre></bdo></b><th id='W9dIV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='W9dIV'><tfoot id='W9dIV'></tfoot><dl id='W9dIV'><fieldset id='W9dIV'></fieldset></dl></div>
                  本文介紹了使用 JavaFX 在任何地方處理鼠標事件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個 JavaFX 應用程序,我想為場景中任意位置的鼠標單擊添加一個事件處理程序.以下方法工作正常,但不完全按照我想要的方式.下面是一個示例來說明問題:

                  I have a JavaFX application, and I would like to add an event handler for a mouse click anywhere within the scene. The following approach works ok, but not exactly in the way I want to. Here is a sample to illustrate the problem:

                  public void start(Stage primaryStage) {
                      root = new AnchorPane();
                      scene = new Scene(root,500,200);
                      scene.setOnMousePressed(new EventHandler<MouseEvent>() {
                          @Override
                          public void handle(MouseEvent event) {
                              System.out.println("mouse click detected! "+event.getSource());
                          }
                      });
                  
                      Button button = new Button("click here");
                      root.getChildren().add(button);
                  
                      primaryStage.setScene(scene);
                      primaryStage.show();
                  }
                  

                  如果我點擊空白區域的任意位置,EventHandler 會調用 handle() 方法,但如果我點擊 buttonEventHandlercode>handle() 方法沒有被調用.我的應用程序中有許多按鈕和其他交互元素,因此我需要一種方法來捕獲對這些元素的點擊,而不必為每個元素手動添加新的處理程序.

                  If I click anywhere in empty space, the EventHandler invokes the handle() method, but if i click the button, the handle() method is not invoked. There are many buttons and other interactive elements in my application, so I need an approach to catch clicks on those elements as well without having to manually add a new handler for every single element.

                  推薦答案

                  您可以使用 addEventFilter().這將在任何子控件使用事件之前調用.下面是事件過濾器的代碼.

                  You can add an event filter to the scene with addEventFilter(). This will be called before the event is consumed by any child controls. Here's what the code for the event filter looks like.

                  scene.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
                      @Override
                      public void handle(MouseEvent mouseEvent) {
                          System.out.println("mouse click detected! " + mouseEvent.getSource());
                      }
                  });
                  

                  這篇關于使用 JavaFX 在任何地方處理鼠標事件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                    <bdo id='QE0Q7'></bdo><ul id='QE0Q7'></ul>
                    1. <legend id='QE0Q7'><style id='QE0Q7'><dir id='QE0Q7'><q id='QE0Q7'></q></dir></style></legend>

                          <tfoot id='QE0Q7'></tfoot>
                        1. <small id='QE0Q7'></small><noframes id='QE0Q7'>

                            <tbody id='QE0Q7'></tbody>
                            <i id='QE0Q7'><tr id='QE0Q7'><dt id='QE0Q7'><q id='QE0Q7'><span id='QE0Q7'><b id='QE0Q7'><form id='QE0Q7'><ins id='QE0Q7'></ins><ul id='QE0Q7'></ul><sub id='QE0Q7'></sub></form><legend id='QE0Q7'></legend><bdo id='QE0Q7'><pre id='QE0Q7'><center id='QE0Q7'></center></pre></bdo></b><th id='QE0Q7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QE0Q7'><tfoot id='QE0Q7'></tfoot><dl id='QE0Q7'><fieldset id='QE0Q7'></fieldset></dl></div>
                            主站蜘蛛池模板: 九九久久精品 | 日韩高清在线观看 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 欧美中国少妇xxx性高请视频 | 成人小视频在线免费观看 | 欧美一区二区在线观看 | 国产一区二区a | 亚洲黄色网址视频 | 九九免费观看视频 | 一区二区三区四区视频 | 午夜影院毛片 | 日韩成人免费视频 | 成人在线视频免费看 | 亚洲三区在线观看 | 欧美亚洲国产一区二区三区 | 51ⅴ精品国产91久久久久久 | 精品9999| 亚洲日本中文字幕在线 | 色狠狠一区| 亚洲国产一区在线 | 激情在线视频 | 色婷婷激情综合 | 日本免费黄色 | 精品欧美一区二区在线观看 | 国产在线a | 亚洲视频中文字幕 | 国产一区二区三区免费 | 天天干成人网 | 97天天干 | 亚洲精品一区中文字幕 | 亚洲视频在线观看一区二区三区 | 一区在线观看视频 | 中文字幕一区在线观看视频 | 91免费观看国产 | 精品真实国产乱文在线 | 国产精品久久久久久久久 | 成人婷婷 | 精品亚洲一区二区 | 久热精品在线 | 天天操天天插 | 日韩中文字幕免费在线观看 |