# Anyone use MigLayout to dynamically make a screen at runtime?

**URL:** <https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [October 20, 2021, 6:56pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180 "2021-10-20T18:56:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 20, 2021, 6:56pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/1 "2021-10-20T18:56:33Z")

</div>

I assume this will only work with vision but it’d be nice to be wrong.

I’ve been doing work with Swing directly in an attempt to learn java and I’ve been using MigLayout which has been really nice. I was wondering if there was a way to use it in Ignition. I’m sure everyones experience the annoyance of accidentally moving a component when you didn’t mean to. It would be nice to be able to add a component to a row, or switch rows of components, by moving a few lines of code, as opposed to physically moving the components.

I came across this post - [Template canvas - Layout Positionning - #2 by nmudge](https://forum.inductiveautomation.com/t/template-canvas-layout-positionning/9660/2)

and see that Nick Mudge had an article about doing so, but that link is unfortunately dead. I was wondering - does anyone here do dynamically creating of screens at runtime? Bonus points for using MigLayout.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 20, 2021, 7:07pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/2 "2021-10-20T19:07:41Z")

</div>

The template canvas natively uses MigLayout when not using absolute positioning. Was using it last week with some variable-sized templates. Carry on.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 20, 2021, 7:09pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/3 "2021-10-20T19:09:06Z")

</div>

Oh so this is only in relation to templates inside a template canvas being able to take advantage of MigLayout, Nick did not mean making a whole screen with MigLayout. Ok ☹

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 20, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/4 "2021-10-20T19:10:50Z")

</div>

Might be possible to subclass Vision’s BasicContainer and drive components with MigLayout. Would have to be a module.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 20, 2021, 7:17pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/5 "2021-10-20T19:17:53Z")

</div>

Darn, I was going to suggest that you could try just setting the layout manager directly in window initialization code, but:

```auto
        if (!(mgr instanceof FPMILayout)) {
            throw new IllegalArgumentException(
                "Cannot set the layout manager for SpringPanel to a non-FPMI layout manager.");
        }

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 20, 2021, 7:19pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/6 "2021-10-20T19:19:39Z")

</div>

I can imagine some cool stuff nesting BasicContainer and a “MigContainer” inside each other.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 21, 2021, 1:24pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/7 "2021-10-21T13:24:10Z")

</div>

Here’s Nick’s article, for posterity.  
[https://web.archive.org/web/20190122061240/http://nickmudge.info/post/ignitions-template-canvas-dynamically-creating-screens-at-runtime](https://web.archive.org/web/20190122061240/http://nickmudge.info/post/ignitions-template-canvas-dynamically-creating-screens-at-runtime)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 21, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/8 "2021-10-21T13:50:03Z")

</div>

Yea I found it via wayback machine. Looks like you have to make the components you want to take advantage of MigLayout in the template canvas it’s own separate template just so you can put it into the template canvas. Makes sense but it’s not exactly what I thought the raticle was going to be about.

I know it’s not in the cards given the whole point of Designer/Ignition is rapid application development with drag and drop functionality so you can get a simple app up and running in hours, but I would love to be able to programatically make the GUI/property changes etc so its all in one file you can look at at one glance and version control a la a java swing app.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 21, 2021, 2:51pm UTC](https://forum.inductiveautomation.com/t/anyone-use-miglayout-to-dynamically-make-a-screen-at-runtime/52180/9 "2021-10-21T14:51:20Z")

</div>

There have been numerous pleas for IA to make Vision’s window XML deterministic and human-editable. Which would also make them git-friendly if used as the resource format. All pleas falling on (not quite) deaf ears, so far. ):
