How to check for empty cells in gridbaglayout? e.g. there are 100 cells, only 10 filled with label or pictures?
+1
A:
Well the GridBagLayout has a getConstraints(Component) method. So you could get all the components in the Container and then get the constraint for each component. The constraint will contain the gridX/gridY value which you could use to populate a 2D array. You may also not to consider the gridWidth/gridHeight values.
So the answer is yes you could derive all the information.
camickr
2010-03-06 16:40:59
+1 : You can derive the values, even though there isn't a direct provision for it in the API.
bguiz
2010-03-07 05:09:11
A:
You could use table2gridbag to avoid producing empty cells in the first place. It's a console tool that takes an HTML table, describing the layout, and transforms it into suitable Java source code for configuring the GridbBaglayoutManager to produce an equivalent layout.
Simon
2010-09-16 14:49:20