I have been using MigLayout for a while and i never encountered this problem. For some reason the hidemode constraint is not working and i can't make it hide a button.
Here is a code snippet that demonstrates it:
import java.awt.Container;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import net.miginfocom.swing.MigLayout;
public class Builder extends JFrame {
private final MigLayout migLayout = new MigLayout("debug, fillx", "[][]", "");
public Builder() {
try {
createAndShowGUI();
} catch (Throwable th) {
th.printStackTrace();
Builder.this.dispatchEvent(new WindowEvent(Builder.this, WindowEvent.WINDOW_CLOSING));
}
}
private void createAndShowGUI() {
Container container = getContentPane();
container.setLayout(migLayout);
JButton b1 = new JButton("b1");
JButton b2 = new JButton("b2");
container.add(b1, "hidemode 1, alignx left");
container.add(b2, "alignx right");
pack();
setResizable(true);
setTitle("Builder");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Builder();
}
}
I am using version 11.0 of MigLayout
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-swing</artifactId>
<version>11.0</version>
</dependency>