|
|
@@ -41,6 +41,17 @@ public class AutoGrowPanel extends JPanel {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private class GrowAction implements AnyActionDocumentListener {
|
|
|
+ @Override
|
|
|
+ public void update(DocumentEvent e) {
|
|
|
+ getBack().removeDocumentListener(this);
|
|
|
+ getBack().addDocumentListener(new DeleteOnEmpty(getBack()));
|
|
|
+ extend();
|
|
|
+ getBack().addDocumentListener(this);
|
|
|
+ getParent().getParent().validate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
IntFunction<DocumentListenable> prod;
|
|
|
AnyActionDocumentListener grow;
|
|
|
List<DocumentListenable> members = new ArrayList<>();
|
|
|
@@ -54,20 +65,16 @@ public class AutoGrowPanel extends JPanel {
|
|
|
|
|
|
public AutoGrowPanel(IntFunction<DocumentListenable> prod, int create) {
|
|
|
this.prod = prod;
|
|
|
-
|
|
|
- this.grow = new AnyActionDocumentListener() {
|
|
|
- @Override public void update(DocumentEvent e) {
|
|
|
- getBack().removeDocumentListener(this);
|
|
|
- getBack().addDocumentListener(new DeleteOnEmpty(getBack()));
|
|
|
- extend();
|
|
|
- getParent().getParent().validate();
|
|
|
- }
|
|
|
- };
|
|
|
+ this.grow = new GrowAction();
|
|
|
|
|
|
setLayout(new VerticalLayout(5));
|
|
|
- while (create-- > 0) {
|
|
|
+ if (create == 0) return; // TODO
|
|
|
+ while (create-- > 1) {
|
|
|
extend();
|
|
|
+ getBack().addDocumentListener(new DeleteOnEmpty(getBack()));
|
|
|
}
|
|
|
+ extend();
|
|
|
+ getBack().addDocumentListener(grow);
|
|
|
}
|
|
|
|
|
|
public <T> AutoGrowPanel(Function<T, DocumentListenable> function, List<T> ingredients) {
|