Path: csiph.com!2.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Thu, 21 Jul 2016 17:49:45 +0200 Organization: Decebal Computing Lines: 33 Message-ID: <87poq756ue.fsf@Equus.decebal.nl> References: <87twfk93vu.fsf@Equus.decebal.nl> <87vazz71ct.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="10772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tMTzVyspV1B60NyMTf/Xcu8u3EPL/API=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:q0W3qh7pTZa1nQ7yQEu/58Jcbww= sha1:ntl3UfIZ6HXEozkH5cwVsU6v6KU= Xref: csiph.com comp.lang.java.programmer:35049 On Thursday 21 Jul 2016 16:58 CEST, Knute Johnson wrote: > On 7/21/2016 03:05, Cecil Westerhof wrote: >> >>> Runnable r = new Runnable() { >>> public void run() { >>> try { >>> ImageIO.write(subImage,"JPEG",new >>> File("crop.jpg")); >>> } catch (IOException ioe) { >>> ioe.printStackTrace(); >>> } >>> } >>> }; >>> new Thread(r).start(); >> >> Why are you doing this in a separate thread? >> > > So if you have a large image that takes a second or two to write it > won't block the Event Dispatch Thread and mess up the mouse > movement. I did not experience that, but I was of-course also selecting the file. I am going to change that anyway: I am going to display it and add a button to save it, so it is only saved after you have verified it is OK. ;-) And then a separate thread probably is a good idea. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof