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

    • <bdo id='mkkow'></bdo><ul id='mkkow'></ul>

      1. <small id='mkkow'></small><noframes id='mkkow'>

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

      2. java.awt.EventQueue.invokeLater 解釋

        java.awt.EventQueue.invokeLater explained(java.awt.EventQueue.invokeLater 解釋)

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

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

                    <tbody id='yarlm'></tbody>
                  本文介紹了java.awt.EventQueue.invokeLater 解釋的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我很好奇為什么我們必須使用java.awt.EventQueue.invokeLater來控制swing組件.

                  I am very curious why do we have to use java.awt.EventQueue.invokeLater to control swing components.

                  為什么我們不能在普通線程中這樣做?幕后究竟發生了什么?從我注意到的情況來看,如果我有一個 JFrame 我可以從主線程將可見性設置為 true 或 false 而不會出現任何錯誤,而且它似乎確實有效.那么使用 java.awt.EventQueue.invokeLater 究竟能實現什么?我也完全知道我可以使用 SwingUtilities.invokeLater 但正如 解釋在這里,它們似乎是一回事.

                  Why can't we do that in normal thread? What exactly is going on behind the scenes? From what I have noticed if I have a JFrame I can set visibility to true or false from the main thread without getting any errors, and it does seem to work. So what exactly do I achieve by using java.awt.EventQueue.invokeLater? I am also fully aware that I can use SwingUtilities.invokeLater but as explained here, they seem to be one and the same thing.

                  感謝任何人的解釋.希望這是一個有效的問題.

                  Thanks to anyone for their explanation. Hopefully this is a valid question.

                  回答 wumpz 問題我們可以創建一個jframe

                  to answer wumpz question We can create a jframe

                  JFrame frame = new JFrame("Hello world");
                  frame.setSize(new Dimension(300, 300));
                  frame.setPreferredSize(new Dimension(300, 300));
                  frame.setMaximumSize(new Dimension(300, 300));
                  frame.setMinimumSize(new Dimension(300, 300));
                  frame.setVisible(true);
                  frame.pack();
                  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                  

                  在創建它的同一線程上執行以下操作.

                  And on the same thread it was created do the following.

                  for (int i = 0; i < 34; i++)
                  {
                      System.out.println("Main thread setting to "+(!frame.isVisible()));
                      frame.setVisible(!frame.isVisible());
                  }
                  

                  沒有抱怨.

                  推薦答案

                  完整的 Swing 處理在一個名為 EDT(Event Dispatching Thread) 的線程中完成.因此,如果您要在此線程中計算一些持久的計算,您將阻止 GUI.

                  The complete Swing processing is done in a thread called EDT (Event Dispatching Thread). Therefore you would block the GUI if you would compute some long lasting calculations within this thread.

                  這里的方法是在不同的線程中處理您的計算,以便您的 GUI 保持響應.最后,您想要更新您的 GUI,這必須在 EDT 內完成.現在 EventQueue.invokeLater 開始發揮作用.它在 Swings 事件列表的末尾發布一個事件(您的 Runnable),并在處理完所有先前的 GUI 事件后進行處理.

                  The way to go here is to process your calculation within a different thread, so your GUI stays responsive. At the end you want to update your GUI, which have to be done within the EDT. Now EventQueue.invokeLater comes into play. It posts an event (your Runnable) at the end of Swings event list and is processed after all previous GUI events are processed.

                  這里也可以使用 EventQueue.invokeAndWait.不同之處在于,您的計算線程會阻塞,直到您的 GUI 更新.所以很明顯,這不能在 EDT 中使用.

                  Also the usage of EventQueue.invokeAndWait is possible here. The difference is, that your calculation thread blocks until your GUI is updated. So it is obvious that this must not be used from the EDT.

                  小心不要從不同的線程更新您的 Swing GUI.在大多數情況下,這會產生一些奇怪的更新/刷新問題.

                  Be careful not to update your Swing GUI from a different thread. In most cases this produces some strange updating/refreshing issues.

                  仍然有 Java 代碼可以從主線程簡單地啟動 JFrame.這可能會導致問題,但不會阻止 Swing.大多數現代 IDE 現在創建類似這樣的東西來啟動 GUI:

                  Still there is Java code out there that starts a JFrame simple from the main thread. This could cause issues, but is not prevented from Swing. Most modern IDEs now create something like this to start the GUI:

                  public static void main(String args[]) {
                      java.awt.EventQueue.invokeLater(new Runnable() {
                          public void run() {
                              new NewJFrame().setVisible(true);
                          }
                      });
                  }
                  

                  這篇關于java.awt.EventQueue.invokeLater 解釋的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)
                          <tbody id='RPpMu'></tbody>

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

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

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

                            <tfoot id='RPpMu'></tfoot>

                            主站蜘蛛池模板: 精品视频在线播放 | 欧美福利一区 | 亚洲精品在线视频 | 三级在线视频 | 亚洲精品一二三区 | www成年人视频 | 午夜精品网站 | 久久精品青青大伊人av | 成人三级视频 | 精品欧美久久 | 精品网 | 日本久久福利 | 免费在线观看av片 | 国产成人精品视频在线观看 | 狠狠狠色丁香婷婷综合久久五月 | 亚洲精选一区 | 久久综合久色欧美综合狠狠 | 搞av.com | 日韩精品一区二区三区中文在线 | 超碰在线97国产 | 亚洲一区二区三区四区五区中文 | 日韩欧美一区二区三区免费观看 | 在线看av的网址 | 国产精品成av人在线视午夜片 | 免费在线观看毛片 | 久久88 | 精品久久久久久久久久久久 | 日本 欧美 国产 | 欧日韩在线 | 欧美精品久久久 | 久久久久国产一区二区三区 | 精品视频在线一区 | 中文字幕av在线 | 午夜丰满寂寞少妇精品 | 九九综合 | 久久精品国产免费一区二区三区 | 日韩国产一区二区三区 | 久久久99精品免费观看 | 在线成人av | www.97国产 | 国产精品日韩一区 |