Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Thu, 21 Jul 2016 12:39:29 -0400 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: <87twfk93vu.fsf@Equus.decebal.nl> <8737n36ucx.fsf@Equus.decebal.nl> <102610cd-cf6f-4f48-aeaa-60669d8bf045@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 21 Jul 2016 16:39:42 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="22e5ab429c5a4bb738666b9c52e40d69"; logging-data="19531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7t01kMUh//ii6PhH+sv1H" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <102610cd-cf6f-4f48-aeaa-60669d8bf045@googlegroups.com> Cancel-Lock: sha1:E0l9knDYky/cjlvnfOfiNDeLb7E= Xref: csiph.com comp.lang.java.programmer:35056 On 7/21/2016 12:03 PM, Eric Douglas wrote: > On Thursday, July 21, 2016 at 9:35:39 AM UTC-4, Eric Sosman wrote: >> I have not studied your code closely, but one thing jumps out: >> You're doing Swingthings on the wrong thread. Almost all of Swing >> is thread-unsafe, and almost all manipulation of Swing objects >> must occur on the Event Dispatching Thread, or EDT. Your code >> breaches this requirement: > > Displaying an image needs to be done on the EDT but can you generate the image in a background thread? Does it come up headless? The image itself is not a Swing component, and has no necessary affiliation with the EDT. Presumably, the image will eventually be painted onto a Graphics instance associated with a Swing component, and that painting operation must happen on the EDT. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM