Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Ian Wilson" Subject: Re: Windows XP Platform L Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 45 Date: Wed, 27 Apr 2011 15:25:59 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303917959 96.60.20.240 (Wed, 27 Apr 2011 10:25:59 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:25:59 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:170 To: comp.lang.java.gui Karsten Lentzsch wrote: > Ian Wilson wrote: > >> I have now tried that (see test app [1] below) but didn't see any >> difference in the button margins. I've had a quick glance at the Looks >> docs but don't yet see where I am going wrong. > > > You must configure the options before you set the look&feel. > Move the line "Options.setUseNarrowButtons(false);" up. > Thanks Karsten, I can now see the effect. >> In my real app, to get equal sized buttons, I am doing this: >> Dimension buttonSize = ( >> new JButton("XXXXXXXX")).getPreferredSize(); >> okButton.setPreferredSize(buttonSize); >> cancelButton.setPreferredSize(buttonSize); >> This is horrible but will suffice until I find something better, or >> until I need to localize the label text, or ... :-) > > > I won't say the above is horrible; it'll scale with > the hardware resolution and font - a good thing. > The width you measure is close to 48 DLU. > But don't use this as preferred size, use it > as minimum size if the layout manager honors that. I find it interesting that, by default, JButtons have minimumSize = preferredSize = maximumSize. My superficial testing yesterday suggested that BoxLayout sizes buttons to their maximumSize, FlowLayout sizes buttons to their preferredSize and GridLayout ignores everything (happily making buttons bigger than their maximumSize). GridBag, of course, is more complicated :-) I'll do more testing with minimumSize - thanks for the tips (and of course for JGoodies Looks etc) --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24