Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Fri, 22 Jul 2016 15:10:19 +0100 Lines: 27 Message-ID: References: <87twfk93vu.fsf@Equus.decebal.nl> <8737n36ucx.fsf@Equus.decebal.nl> <878twu6i0l.fsf@Equus.decebal.nl> <87vazy4zm2.fsf@Equus.decebal.nl> <87r3am4q2l.fsf@Equus.decebal.nl> <87mvla4dlt.fsf@Equus.decebal.nl> <38012169-26ac-47b4-91c9-cfbb84d8c042@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ZhgWtBa/OFOy3figphJJBQkOJF/nJ87YYTMoXujH6I86195qOC Cancel-Lock: sha1:f+0LY2WJR0h1KOiy+waYHK8Nlw0= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 In-Reply-To: <38012169-26ac-47b4-91c9-cfbb84d8c042@googlegroups.com> Xref: csiph.com comp.lang.java.programmer:35086 On 22/07/16 13:16, Eric Douglas wrote: > On Thursday, July 21, 2016 at 10:44:50 PM UTC-4, Eric Sosman wrote: >> "Good," I think. Letting layout managers do their thing relieves >> you of worries like "How much room should I leave for borders?" and >> "Will the amount of border-room be different on other devices or other >> look-and-feel settings?" >> >> YMMV, but speaking for myself: I've used null layout only with >> panels I treat as "canvases" or "drawing surfaces," panels that display >> images or vector drawings or other "painted" things as opposed to >> "contained components." I do not recall ever using a null layout on >> a top-level container. > > I normally use a null layout and give everything an absolute size and position, which seems the easiest thing to do when you have a minimum window size to work with and you don't need resize-able controls. > How do you cope with a different display, or a different OS, with different fonts/font metrics, or a display with a different resolution and/or scaling factors? Presumably you have to manually calculate the size of every control, taking into account the insets/margins etc. then the containers, and so on up the hierarchy. > I tried using a non-null layout once and the only thing I could get to look right with a handful of controls at different sizes and positions was a GroupLayout, though it's a bit complicated to get right. I've heard this is what NetBeans does. > Gridbag and Border are the main layouts I use. There's pretty much nothing I've ever constructed in a GUI which couldn't be managed by a suitable combination of those two layouts. The key to any GUI is not to try to force every component into the same container, and then try to micro-manage the layout. Instead use multiple containers, containers within containers, each using their own layout, until you get the desired effect. I do nearly everything in NetBeans/Matisse, only tweaking things by hand where necessary. These are tools which make my life much easier/simpler, so I use them. Even on the rare occasions where I decide I need to code a GUI by hand I generally run a mock-up in Matisse to get the basic layout, and then copy the components and layout configuration into my custom GUI. It's just so much easier, and quicker, to use NetBeans/Matisse to generate a GUI, and all the associated boiler-plate.