Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 12 Jan 2012 10:16:42 -0600 Content-Type: text/plain; charset="ISO-8859-1" From: "A. W. Dunstan" Organization: OptiMetrics, Inc. Date: Thu, 12 Jan 2012 11:16:37 -0500 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: JTable, JScrollPane and empty space Newsgroups: comp.lang.java.gui References: Followup-To: comp.lang.java.gui MIME-Version: 1.0 Message-ID: Lines: 70 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 50.77.194.237 X-Trace: sv3-XCVjxCB4G+uJPyKWyb/E5LfucZAe92wQd/Hhu3nCK+yfpCUHbCRw5XcrbKXTgqZAdYC9nycbDl0pNQ2!hI/W6nqupn5qR+/zUADaumy81z7Sjoi80X/1HkxaH5I50DmeH+LO3DehefDzoJaJA8Xh9DBAu5xJ!WVIhXbeoxt3EgMpI9i+EidBePzePM787TM8= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4607 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4926 Thanks for looking - I'll give those a try. The 'full-sized' version of this has a grid of several different components, used for entering parameters that will then be fed to an engineering simulation package. The 1st column (not shown in my sample code) is either empty or a checkbox, the 2nd is a label (tells the user what value they're entering and it's units), the 3rd column is the value they'll enter. The JTables are for enumerated values; I use JSpinners for scalar values, and a custom component for when the user wants to run the simulation over a range of values (height of 20 meters vs height of {10, 20, 30, 40, 50} meters). The checkbox lets the user switch between scalar and range-of-values. So the underlying problem is pretty much grid oriented, which led me to GridBagLayout initially. GridLayout wants to make all the rows the same height & all the columns the same width, but my rows are of varying heights (ditto the columns). I didn't think nested BoxLayouts would keep the rows _and_ columns lined up. GroupLayout is a possibility. thanks again! wrote: > I think I see what is going on. I haven't double checked (modified the > code to see if I'm right) but I think the issue is that you are adding > components horizontally. That is you add the label and the table in one > row, and then you add another label and table for the next row. > > That would allow the components to expand horizontally, if they needed > to, but you want the tables to be able to expand vertically. So the > basic approach isn't going to work. > > Take a look at this example from the tutorial. Notice that button 4 > spans three cells in the grid bag layout and expands as needed: > > > > What you want to do I think is take John's suggestion to use something > like a Box or Flow layout. Make a JPanel, and make it the last > component (or only component) in the last column, like button 4 is the > only component in the tutorial example. Then instead of adding the > tables to the grid layout directly, you'll add them to the panel. > > That should let the panel expand up and down, like button 4 does, but > also its layout (box or flow) will scoot the tables up and down as > needed. Grid bag is a *grid*, so it always tries to keep things lined > up. They can't flow up and down as needed on their own with just grid > bag. > > In general, this is an easy way to make layouts do what you want, > composing layouts out of other, smaller layout components. I find it > easier to "see" what the components will do, rather than trying to find > one big layout that does everything you want. > > You might also be better served by other layouts, like Spring, but it's > hard to say as I don't know your actual requirements. Making the last > component in your existing layout into a JPanel and adding the tables to > that is the least intrusive change I can think of. -- Al Dunstan, Software Engineer OptiMetrics, Inc. 3115 Professional Drive Ann Arbor, MI 48104-5131 "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." - C. A. R. Hoare