To answer Ralph, panel2 and panel 3 each have an image behind them. Panel1 and panel 4 do not have an image behind them. Panels 2 and 3 actually have related controls, but panel 2 uses five controls and panel 3 only needs the first and the third one. So controls 1 and 3 should line up, but panel 3 should not display the other controls. Panel 1 has labels for four of the controls. Panel 4 is completely unrelated to the other panels in terms of what the controls are used for, I just thought it looked better to have the components line up with the other 3 panels. rather than have them at an arbitrary location. The 'requirement' I am working from requires stacking 3 components on top of each other vertically. It would actually have made more functional sense to place panel 4 underneath the other three panels. But I don't have enough vertical height and I have plenty of width. Not also, if the same control appeared in a given row, life would be easier. But one column has a label in column 1, a combo box in column 2, nothing in column 3 and a checkbox in column 4. GridBagLayout, for example, gives these controls different heights.
Anyway, setting up a GridBagLayout with 4 columns would solve my horizontal alignment problems. But then I would need to place an image underneath just column 2 and another image just underneath column3 and have the images resize in synch with the columns. That's why I chose to use four panels and then try to get the controls aligned across the panels. Also, the image needs to be wider than the control in the column, but that seems manageable (though not clear how to increase the inset width with the column width). I am willing to concede that the basic concept for implementing this requirement is misguided and throw it out. I'm just not able to think of something clever to substitute it with.
Here is a picture (attached) of the package panel happily displayed in it's own test frame. Note, I haven't implemented the actual values of the combo boxes and in column 2 the other fields will actually be Double text fields. So the labeling is not as redundant as it looks at the moment. Also, I was planning to put a layer over 'blister', for example, when it was unchecked to better indicate the active panel. Then I could possibly remove the check boxes and find room to move panel 4 to a horizontal line under the other three panels. Note that the bottle labels are inside the bottle now, but if I widen the window, since the insets to the controls are a fixed size, I end up with the controls being wider than my bottle.
Ranga, I will try to put an
SSCCE together. The code currently is 1600 lines. My problem is that I'm not really understanding the relationship between final size and preferred size. As I remove elements, the panel size shrinks. I thought I could create an example where I had dummy panels where I just set a size, i.e.,
but when I put my 'real' package panel (with a requested size of 300,225) and real excipient panel (with a requested size of 300,235) then the GUI displays with the humidity panel squeezed down to about 100 pixels and the excipient panel expanded to larger than I need it to be (and larger than the window that comes up when I just create a test file to display just that panel in a 300x235 frame. I'm have trouble seeing how to make a simple example in those conditions, since leaving things out changes the behavior. I'm not totally convinced that if I put real panels on the left side, that Java wouldn't shrink the right side, which is doesn't do with a dummy like the one above, even if I ask for a width of 800.
So I think I need to create several examples that cover different aspects of the problem, where by problem I really mean something that I don't understand why I get the behavior I see. That may take a little time.