Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Thu, 21 Jul 2016 21:30:08 -0000 (UTC) Organization: A noiseless patient Spider Lines: 38 Message-ID: References: <87twfk93vu.fsf@Equus.decebal.nl> <8737n36ucx.fsf@Equus.decebal.nl> <878twu6i0l.fsf@Equus.decebal.nl> <87vazy4zm2.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 21 Jul 2016 21:30:08 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="16117"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19x3WXB9D4tM+zcUOgS6+Fw0EAxpa9aLn4=" User-Agent: Pan/0.140 (Chocolate Salty Balls; GIT 3663720 git://git.gnome.org/pan2) Cancel-Lock: sha1:QLoCYmw46ZianX/3o/6tsmMG8v4= Xref: csiph.com comp.lang.java.programmer:35072 On Thu, 21 Jul 2016 15:37:55 -0400, Eric Sosman wrote: > On 7/21/2016 2:25 PM, Cecil Westerhof wrote: >> [...] >> I just have one little problem. At the moment I do: >> crop.setBounds( 10, imageHeight + 10, 80, 30); >> load.setBounds( 110, imageHeight + 10, 80, 30); >> imageInfo.setBounds( 10, imageHeight + 50, 500, 30); >> selectInfo.setBounds(10, imageHeight + 90, 500, 30); >> setSize(imageWidth + 10, imageHeight + 160); >> >> because title and things like that takes room, but I do not know how >> much. How can I retrieve these values? Then the application looks a >> little better and I do not have to be afraid it will not be OK on other >> platforms. > > Possibly useful as a starting point: > > Dimension screenSize = > Toolkit.getDefaultToolkit().getScreenSize(); > > (Disclaimer: I've only used this on single-screen machines; you need to > work harder if there are multiple displays.) > Same here. I specify major component sizes, i.e. JPanel, etc. as percentages of the screen size returned by the Toolkit. The only components I specify in pixels are text-related components, where the component size determines whether the text gets cropped. I suppose I should work back the other way by basing the component size on the size and font used by the text it displays, but so far I've hand-tuned this and found that it has worked acceptably on different-sized screens, but maybe I've just been lucky. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |