mikaelgrev/miglayout

Could "temporary default component constraints" be added?

Opened this issue · 0 comments

vlsi commented

Use case:

apache/jmeter#513

I want to build a JPanel for the right part of the window.

The case there is:

Name:      _____
Comments:  _____
...

In current implementation, "name and comments" is its own MigLayout("fillx, wrap 2, insets 0", "[][fill,grow]")

The problem: what if I want to add some fields below Name and Comments?

If I just call panel.add(component), then it would add the component to the first cell.
Of course, the workaround would be panel.add(extraComponent, "span 2"), however, it does not work if I want the UI to be extensible.
In other words, the one who adds extraComponent does not really know that name/comments is structured as two columns.

What if the was MigLayout#setDefaultComponentConstraintsForNextComponents(String)?
Then I could create my name/comments panel as two-column panel, then I call setDefaultComponentConstraintsForNextComponents("span 2") and everyone else who adds components would automatically get span 2 constraint.

On the other hand, the one who cares could either reset the default or override it by using span 1. Then one could add Description: _____ field which would align nicely with Name/comments fields.

Does the above make sense?