{"id":6971,"date":"2014-05-16T01:15:07","date_gmt":"2014-05-16T01:15:07","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/problem-about-event-dispatch-thread-collection-of-common-programming-errors\/"},"modified":"2014-05-16T01:15:07","modified_gmt":"2014-05-16T01:15:07","slug":"problem-about-event-dispatch-thread-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/problem-about-event-dispatch-thread-collection-of-common-programming-errors\/","title":{"rendered":"problem about event-dispatch-thread-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4890a3bacfa315f90ffbc60d69c3e7c7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nIgor Nardin<br \/>\njava swing event-dispatch-thread shutdown-hook<br \/>\nI have a Swing application that handles Ctrl+C using addShutdownHook(), and it works fine until one of the shutdown tasks I have calls a function that under normal circumstances changes a JLabel text, at which point it hangs.I assume the problem is that the Swing EDT has either terminated or is waiting for something.Is there a way to either determine that the EDT has terminated or is &#8220;done&#8221; (so I can avoid calling Swing methods), or to prevent the usual close-all-the-windows-down behavior on Ctr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a62aea56f0834853a2310e8691c8911e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmKorbel<br \/>\njava swing concurrency jbutton event-dispatch-thread<br \/>\nThe Button color is not getting updated rather didn&#8217;t show normally as well as dynamically when i run my application. this problem occurs only on Linux environment and the same code work fine with windows.can any one suggest? private JButton button = new JButton();button.setLayout(buttonLayout);button.add(totalsLabel, BorderLayout.CENTER);totalsLabel.setHorizontalAlignment(JButton.CENTER);button.add(statusLabel, BorderLayout.SOUTH);statusLabel.setHorizontalAlignment(JButton.CENTER);button.setMar<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a62aea56f0834853a2310e8691c8911e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmKorbel<br \/>\njava swing concurrency event-dispatch-thread<br \/>\ni&#8217;m programming a blackjack (single thread) for a university project and the dealer is the computer (e.g. no player action)&#8230;Does someone know how can I program in Java something like this:while (dealerpoints &lt; 17)open card and repaint framewait 1 sec (to run again the condition test for while)THe thing is, I don&#8217;t want all dealer cards painted at once&#8230;Thanks in advance, Gabriel SoteroUPDATE: this is my code (that doesn&#8217;t work)while (Dealer.getInstance().dealerPoints &lt; 17){Dealer.getIns<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/AuY9o.png?s=32&amp;g=1\" \/><br \/>\nAndrew Thompson<br \/>\njava swing event-handling wait event-dispatch-thread<br \/>\nWhat is the proper way to implement the following code? I want to get the takeTurn() method to wait for the player to click on a button on the grid corresponding to the piece he wants to select. (Button objects have instance variables int col, row and extend JButton.)int selectedCol, selectedRow;void takeTurn() {System.out.print(name + &#8220;&#8216;s turn. &#8220;);\/\/ Get player to select a pieceselectedCol = -1;selectedRow = -1;while (selectedCol == -1 &amp;&amp; selectedRow == -1) {try {wait(500);} catch (Inte<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bdb0ce174868c8c95261471d4663484f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGypsa<br \/>\nobjective-c ios asihttprequest crash-reports event-dispatch-thread<br \/>\nI am developing an application in which a lot of operations are added in ASINetworkQueue.The operations are basically used for fetching the image from server and then in successful completion set the image in table view cell.Everything is happening fine.I have a button a table view cell on which another view controller gets opened.On that another view there is a cross button on which I pop that view controller. Now when the cross button gets clicked sometimes the app gets crashed there, sometime<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a62aea56f0834853a2310e8691c8911e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmKorbel<br \/>\njava swing event-dispatch-thread jprogressbar thread-sleep<br \/>\nI have a JProgressBar and want to be able to see it dynamically updated. The progress bar should be able to visibly move from one position to another, not just change without the bar visibly changing (think regular loading bars).public static void dropHPBar(int before, int after) {Thread.currentThread.sleep(50);while (before &gt; after) {try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}GameMain.gW.setHP(before);b &#8211;;}and from GameMain.gW:public void setHP(int x) {hpBa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b38ca05c2d7ebae9a3a75afb817af33f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCedric Martin<br \/>\nswing exception clojure event-dispatch-thread<br \/>\nI&#8217;m trying to implement a &#8220;complete&#8221; uncaught exception handler, allowing to also catch EDT exceptions in Clojure.I&#8217;m trying to implement the class from the accepted answer (with 15+ upvotes) from here:How can i catch Event Dispatch Thread (EDT) exceptions?Here&#8217;s the part that I&#8217;d like to port to Clojure:public static class ExceptionHandler implements Thread.UncaughtExceptionHandler {public void handle(Throwable thrown) {\/\/ for EDT exceptionshandleException(Thread.currentThread().getName(), thro<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/767447312a2f39bec228c3925e3edf74?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkyle_wm<br \/>\njava eclipse debugging swing event-dispatch-thread<br \/>\nThis is a minor annoyance I have when debugging with Eclipse. With &#8220;Suspend execution on uncaught exceptions&#8221; checked, the debugger will normally suspend a thread right where the exception was thrown. Exceptions on the Event Dispatch Thread, however, cause it to pause on the last line of EventDispatchThread.run(). There is no useful information about what the exception is or what caused it until I resume the thread to allow the stack trace to print to the console. Debug the following code in Ecl<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/684f877a8c069b990bde2bdbff017c58?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKelly Ann<br \/>\njava swing gui jlabel event-dispatch-thread<br \/>\nI have question about my homework the coin program. We need write a small GUI program which could flip the coin and can show the current money.I wrote almost everything, but I still have some problem to update two JLabel status and it seems like the two bet buttons and reset the button are work fine, after I use System.out.println to testing, but the label just not update as the same time when we click the button. Here is my codes, which contain four class: coin.java, player.java, coinpanel.java<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/88fd507087a8b5e0081f5d554320b6a7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOmar Munoz<br \/>\njava swing jlabel repaint event-dispatch-thread<br \/>\nHi I am trying to create a gui that will update the temperature every time the temperature sensor sends back a signal and update the jlabel value. Right now I am able to update the gui label by pressing the update button, however i want it to update automatically without pressing the &#8220;update button&#8221;. I have tried a lot of method including repaint(), and revalidate(), and using different type of swing timers but still cannot get it to work. Can someone please help me out here? Thanks I will post<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a62aea56f0834853a2310e8691c8911e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmKorbel<br \/>\njava nullpointerexception scheduled-tasks jfilechooser event-dispatch-thread<br \/>\nI have a program that would send emails with attachments to users. The program should be ran according to the scheduled time, and because of that I use task scheduler to do it for me. I did all necessary steps to make this happen. (create .bat file to activate\/run the jar file then task scheduler will trigger the .bat file if it hits the stated schedule.) The problem right now is that when the program is ran or is triggered by task scheduler, it gives off this error:java.lang.NullPointerExceptio<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/39f30d17fce14127ecab84a4bc8568c6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1666950<br \/>\njava swing look-and-feel event-dispatch-thread substance<br \/>\ni&#8217;m trying to use the substance 6.0 look and feel. I added substance.jar and trident.jar to my build path. My Code looks like this:public class phaseTwoGame extends JFrame {public phaseTwoGame(){ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setUndecorated(true);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds(0,0,screenSize.width, screenSize.height);add(new MainPanel()); }public static void main( String[] args ){try {UIManager.setLookAndFeel(&#8220;org.p<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n<p>I discovery a place to host code\u3001demo\u3001 blog and websites.<br \/>\nSite access is fast but not money<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.m5zn.com\/newuploads\/2014\/01\/30\/jpg\/e7da807964b1fff.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Igor Nardin java swing event-dispatch-thread shutdown-hook I have a Swing application that handles Ctrl+C using addShutdownHook(), and it works fine until one of the shutdown tasks I have calls a function that under normal circumstances changes a JLabel text, at which point it hangs.I assume the problem is that the Swing EDT has either terminated [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6971","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6971"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6971\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}