settingDialog = stn;
}
+ /**
+ * Rebuilds the Options and Parameters panels
+ */
@Override
public void refreshParamLayout()
{
int hgap = 5;
int currentWidth = hgap;
+ /*
+ * layout constraint 'nogrid' prevents vertical column alignment,
+ * allowing controls to flow without extra space inserted to align
+ */
optionsPanel.setLayout(new MigLayout("nogrid", "", ""));
optionsPanel.removeAll();
-
JPanel lastAdded = null;
+
+ /*
+ * add each control in turn; if adding would overflow the right margin,
+ * remove and re-add the previous parameter with "wrap" (after)
+ * in order to start a new row
+ */
for (OptionBox pbox : opanp.getOptSet().values())
{
pbox.validate();
for (ParamBox pbox : opanp.getParamSet().values())
{
pbox.validate();
- currentWidth += pbox.getSize().width + hgap;
- if (currentWidth /*+ 160*/ > availableWidth && lastAdded != null)
+ int boxWidth = pbox.getSize().width;
+ currentWidth += boxWidth + hgap;
+ boolean wrapAfterLast = currentWidth > availableWidth
+ && lastAdded != null;
+ if (wrapAfterLast)
{
paramsPanel.remove(lastAdded);
paramsPanel.add(lastAdded, "wrap");