久久久久久久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 解釋的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

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

                  為什么我們不能在普通線程中這樣做?幕后究竟發(fā)生了什么?從我注意到的情況來看,如果我有一個 JFrame 我可以從主線程將可見性設(shè)置為 true 或 false 而不會出現(xiàn)任何錯誤,而且它似乎確實有效.那么使用 java.awt.EventQueue.invokeLater 究竟能實現(xiàn)什么?我也完全知道我可以使用 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 問題我們可以創(chuàng)建一個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);
                  

                  在創(chuàng)建它的同一線程上執(zhí)行以下操作.

                  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 保持響應(yīng).最后,您想要更新您的 GUI,這必須在 EDT 內(nèi)完成.現(xiàn)在 EventQueue.invokeLater 開始發(fā)揮作用.它在 Swings 事件列表的末尾發(fā)布一個事件(您的 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.在大多數(shù)情況下,這會產(chǎn)生一些奇怪的更新/刷新問題.

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

                  仍然有 Java 代碼可以從主線程簡單地啟動 JFrame.這可能會導(dǎo)致問題,但不會阻止 Swing.大多數(shù)現(xiàn)代 IDE 現(xiàn)在創(chuàng)建類似這樣的東西來啟動 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);
                          }
                      });
                  }
                  

                  這篇關(guān)于java.awt.EventQueue.invokeLater 解釋的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?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>

                            主站蜘蛛池模板: 亚洲成人动漫在线观看 | 亚洲午夜视频 | 91麻豆精品国产91久久久久久久久 | 91久色| 日韩黄色在线视频 | 四虎影院免费观看 | 中文字幕1区 | 青青草国产成人av片免费 | 亚洲在线一区 | 欧美在线视频免费观看 | 亚州成人 | 国产一区亚洲 | 99久久综合 | 91欧美大片 | 国产精品久久久久永久免费看 | 人与拘一级a毛片 | 日韩成人精品一区二区 | 国产精品国产精品国产专区不片 | 免费性网站 | www.久久久 | 日日爱视频 | 日韩一级大片 | 日本高清www | 国产精品av一区二区 | 伊人免费视频 | 欧美日韩国产一区 | 国产一区二区三区视频在线 | 婷婷综合网 | 欧美一级网站 | 国产高清视频一区 | 欧美精产国品一二三区 | 久久精品在线观看 | 99视频在线 | 久久久青草 | 日本特黄特色aaa大片免费 | 国产又色又爽又黄又免费 | 精品国产区一区二 | 91在线看片 | 手机在线免费看av | 日韩av专区 | 四虎影视av |