With a JPanel using MigLayout, when I use setLocation(x,y); when dragging another JPanel inside this panel, the location of the component is reset to the absolute positioning component constraint (specified when adding the component). For example:
this.add(content, "pos 50 50");
...
//dragging
content.setLocation(x,y);
When I do this, it successfully changes the x/y location of the content, but is reset again as soon as the outer (this) panel is resized or validated.
I’ve tried the following code but the panel doesn’t move on drag at all:
migLayout.setComponentConstraints(content, "pos " + x + " " + y);
How can I get around this?
Thanks.
Add the keyword external to the component constraint when you want Miglayout to not place it, like while dragging.
The more general answer is just like Kleopatra say.