Path: csiph.com!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: Fri, 22 Jul 2016 10:27:16 +0200 Organization: Decebal Computing Lines: 84 Message-ID: <87invy3wnv.fsf@Equus.decebal.nl> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="26143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QK4UWrUi/sx1v5/G5mGstb8082leuxfs=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:PuLQyf+z1Fj2gvggF+QCEg8P/NA= sha1:kpp/tUEEJL6ZbE09AJe1Sc0fnRU= Xref: csiph.com comp.lang.java.programmer:35080 On Friday 22 Jul 2016 04:44 CEST, Eric Sosman wrote: > On 7/21/2016 10:21 PM, Cecil Westerhof wrote: >> On Friday 22 Jul 2016 02:35 CEST, Eric Sosman wrote: >> >>> Okay, I may have misinterpreted your need. However, it looks to me >>> as though your difficulty is self-inflicted by your insistence on >>> using absolute positioning. If you used a layout manager instead, >>> you'd just setPreferredSize() on the image-displaying panel (which >>> might well have a null layout manager), and Swing would figure out >>> the dimensions of title bars, menu bars, scroll bars, sand bars, >>> stars and bars, and all the rest. >>> >>> But since you want to use absolute positioning, well, ... (Shrug.) >> >> No, I do not want to use absolute positioning, but without it I did >> not get it working. I now use BoxLayout, I am not there yet, but I >> am on the right path. I still have a few quirks. I will post those >> soon. > > "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. A null layout did not work, but BoxLayout works not completely. I have the following code: boolean sameLine = false; setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); d.setSize(80, 30); crop.setPreferredSize(d); load.setPreferredSize(d); d.setSize(500, 30); imageInfo.setPreferredSize(d); selectInfo.setPreferredSize(d); add(panel); if (sameLine) { buttons.setLayout(new FlowLayout()); buttons.add(crop); buttons.add(load); add(buttons); } else { add(crop); add(load); } add(imageInfo); add(selectInfo); pack(); With sameLine = false I get: https://drive.google.com/file/d/0BzW5q7uL-6z0eERBS3B1RE1jZEU/view There are two things I do not understand: - There is a grey area beside the picture. - The buttons are not exactly the same length. But these are minor, so those can wait. When I change sameline to false I get: https://drive.google.com/open?id=0BzW5q7uL-6z0em91OW14VW1Qakk Here the buttons are on the same line as I want them to be. But there are two problems: - The buttons are made very big. They fill the complete line and make it even bigger. I want them have the size of the previous one and displayed like in this picture: https://drive.google.com/open?id=0BzW5q7uL-6z0XzNJb0FSRFFxMDA - imageInfo and selectInfo are moved to the right. Why is this happening? I would like the buttons displayed as in the third picture and the info lines as in the first picture. How would I do that? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof