Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: JPanel and paintComponent different results between Windows/Linux Date: Mon, 07 Sep 2015 21:21:48 -0400 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: <64b2edb0-379c-4e60-b985-891d9c0a320c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 8 Sep 2015 01:21:39 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a78aad8b483612fbf45d18e918df0cca"; logging-data="9417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18e0FhXQQApxIw2ou6lCT7j05PEmcNfV+Q=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 In-Reply-To: <64b2edb0-379c-4e60-b985-891d9c0a320c@googlegroups.com> Cancel-Lock: sha1:AwEBVlOJO15VSPN616cCwaM5oRw= Xref: csiph.com comp.lang.java.programmer:32556 On 09/07/2015 08:27 PM, Dark Mornings wrote: > Hello. I have a small program that displays a bar graph of 5 bars of varying lengths. The bars display in Windows but not in Linux. I used NetBeans 8/JDK 1.8 to compile the code in Windows and OpenJDK in Ubuntu 14.04. I know paintComponent() is called because I inserted a println() statement into the body of the do-while loop and saw the output. It seems paintComponent() is called 3 times. > > Why does the my program work in Windows but not in Linux? > You have code that needs to run on the AWT event thread; public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { new BarGraph(); // or however you want to arrange it. } }); You should handle your InputDialog cancel option.