How to show JLabel ellipsis in MigLayout?

Using the default layout manager, JLabel displays its ellipsis when the frame size changes.

As it shown on the picture:

public static void main(String[] args) {
    final JFrame jFrame = new JFrame("JLabel, show me your ellipsis!");

    jFrame.getContentPane().add(new JLabel("Sure darling! Shrink me and I'll show you"));

    jFrame.pack();
    jFrame.setVisible(true);
}

However, MigLayout does not display this behavior!

public static void main(String[] args) {
    final JFrame jFrame = new JFrame("JLabel, show me your ellipsis!");

    jFrame.getContentPane().setLayout(new MigLayout());
    jFrame.getContentPane().add(new JLabel("Nope! I just do not know you well enough!"));

    jFrame.pack();
    jFrame.setVisible(true);
}

I tried all the layout / component restrictions that I could think of. Does anyone know if this is possible in Mig?

+5
source share
1 answer

JLabel has a minimum size that roughly (or not exactly remembered) matches its preferred size. MigLayout only compresses the component to a minimum. Therefore, you need to add a component constraint that allows a size smaller than its minSize:

content.add(label, "wmin 10lp");
+5
source

All Articles