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

      <legend id='j0Hqu'><style id='j0Hqu'><dir id='j0Hqu'><q id='j0Hqu'></q></dir></style></legend>

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

      <tfoot id='j0Hqu'></tfoot>

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

      2. Java - Swing 中的 mouseMoved() 事件處理

        Java - mouseMoved() event handling in Swing(Java - Swing 中的 mouseMoved() 事件處理)

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

          1. <tfoot id='Nf4JY'></tfoot>

              <tbody id='Nf4JY'></tbody>

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

                • 本文介紹了Java - Swing 中的 mouseMoved() 事件處理的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想在我的 JFrame 中監聽鼠標移動和點擊.為此,我添加了一個像這樣實現的 MouseListener:(View 類的整個代碼位于 https://gist.github.com/2837224,Board 類在 https://gist.github.com/2837231)

                  I want to listen for mouse movements and clicks in my JFrame. To do this, I've added a MouseListener implemented like this: (whole code of View class is at https://gist.github.com/2837224, Board class is at https://gist.github.com/2837231)

                  class BattleshipsFrame extends JFrame {
                    private final Board playerBoard, opponentBoard;
                    private View view;
                  
                  /** Main window constructor. */
                  BattleshipsFrame() {
                    ...
                    ...   
                    ...
                    //creating and displaying boards
                    playerBoard = new Board();
                    opponentBoard = new Board();
                    PlayerBoardListener mouseListener = new PlayerBoardListener();
                    this.addMouseListener(mouseListener);
                    playerBoard.addMouseListener(mouseListener);
                    opponentBoard.addMouseListener(new OpponentBoardListener());
                    boards.add(playerBoard);
                    boards.add(opponentBoard);
                    ...
                    ...
                    ...
                  }
                  
                  /** Listener responsible for handling mouse events on player board */
                  private class PlayerBoardListener extends MouseAdapter {
                    @Override public void mousePressed(MouseEvent event) {
                      try {
                        if(event.getButton() == MouseEvent.BUTTON1 && controllerConnection != null)
                          controllerConnection.sendShipPlacedEvent(event.getX()/40, event.getY()/40, ShipType.EMPTY);
                      } catch(Exception e) {
                        e.printStackTrace();
                      }
                    }   
                    @Override public void mouseMoved(MouseEvent event) {
                      //TODO
                      System.out.println("Mouse movement detected! Actual mouse position is: " + event.getX()+ "," + event.getY() + ".");
                    }   
                    @Override public void mouseDragged(MouseEvent event) {
                      //TODO
                      System.out.println("Mouse movement detected! Actual mouse position is: " + event.getX()+ "," + event.getY() + ".");
                    }   
                  
                  }
                  

                  有趣的是 mousePressed() 運行良好,但其他兩個卻沒有(移動鼠標時控制臺上沒有顯示).誰能告訴我我做錯了什么?提前致謝!

                  Funny thing is that mousePressed() is working well, but the other two are not (nothing shows on console while moving the mouse). Anybody could tell me what am I doing wrong? Thanks in advance!

                  推薦答案

                  如果要接收 mouseMovedmouseDragged 事件,還需要將監聽器注冊為MouseMotionListener.

                  If you want to receive mouseMoved and mouseDragged events, you need to also register your listener as a MouseMotionListener.

                  MouseAdapter adapter = ...
                  JFrame frame = ...
                  frame.addMouseListener(adapter);
                  frame.addMouseMotionListener(adapter);
                  

                  這篇關于Java - Swing 中的 mouseMoved() 事件處理的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)

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

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

                          <tbody id='gtKAL'></tbody>

                          <legend id='gtKAL'><style id='gtKAL'><dir id='gtKAL'><q id='gtKAL'></q></dir></style></legend>
                            <bdo id='gtKAL'></bdo><ul id='gtKAL'></ul>
                            <tfoot id='gtKAL'></tfoot>
                            主站蜘蛛池模板: 亚洲欧美一区二区三区视频 | 日韩精品1区2区3区 国产精品国产成人国产三级 | 精品真实国产乱文在线 | 精品国产青草久久久久福利 | 欧美激情综合 | 嫩呦国产一区二区三区av | 毛片a级| 中文字幕在线视频观看 | 国产网站在线免费观看 | 精品视频一区二区三区在线观看 | 不卡视频在线 | 国产精品久久久久久 | 在线一区| 亚洲午夜视频在线观看 | 国产yw851.c免费观看网站 | 男女一区二区三区 | 精品一区二区三区在线观看国产 | 亚洲一区二区三区在线 | 欧美激情视频一区二区三区免费 | 国产一级免费视频 | 亚洲欧美日韩国产综合 | 人人色视频 | 久久中文一区二区 | 日韩av一区二区在线观看 | 亚洲精品一级 | 精品婷婷| 中文字幕加勒比 | 做a网站 | 欧美日韩亚洲一区 | 综合一区| 久久久久亚洲 | 国产视频一区二区 | 97色免费视频 | 日韩久久久久久 | 99久久久国产精品 | 特级一级黄色片 | 91精品亚洲 | 欧美日韩在线一区二区 | 欧美一区视频 | 91最新视频 | 伊人超碰在线 |