Weird MigLayout

Not sure where to put this so I put it in General Discussions and hope for the best.

What you are seeing from the attached image is some weird behavior from MigLayout, my favourite LayoutManager in Java (I’m sure I’m not the only one).

http://www.java-gaming.org/index.php?action=dlattach;topic=20665.0;attach=1418;image

I have placed a JTextArea inside a JPanel. What’s weird is the extra space that appears between the two borders. It should not be there! If I place the JTextArea in the north/south/west/east it is not there, but it is there when I place it in the center. I need it to be in the center since I want it to be able to grow both horizontally and vertically.

Here’s the short piece of code:

public class Log extends JPanel {
    private JTextArea ta = new JTextArea("haha");
    public Log() {
        setLayout(new MigLayout("fill"));
        setBorder(BorderFactory.createLineBorder(Color.BLUE));
        ta.setBorder(BorderFactory.createLineBorder(Color.BLUE));
        add(ta, "grow, center");
    }
}

If you haven’t heard of MigLayout before, welcome to layout heaven. :slight_smile: http://www.miglayout.com/

Anyway this is the first time MigLayout haven’t made sense to me, why is there 7 pixels of space between the borders? Is it something with JPanel that needs tweaking? Some sort of padding maybe?

Edit: Fixed tabs, added image above.

Try

new MigLayout("insets 0, fill")

And if it works, slap yourself for not adhering to RTFM, since I never heard of MigLayout and just took a look in the QuickStart.pdf :o

[quote=“cylab,post:2,topic:33716”]
I slapped myself hard on both cheeks. Seriously.

At least this thread will help introduce some to the MigLayout. :smiley: Help making it an official part of JDK 7! Cast your vote here:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6530906

People tend to forget that once something makes it into the JRE, it’s basically frozen instantly, due to ‘backwards compatibility’ stuff.

Swing, for one, would have been a heck of a lot better off as a standalone package. It could have actually been something that worked reliably across all JREs, as you simply shipped your own version - you know, the one that worked!

So before you ask for ‘great package N’ to be added to the JRE, you might think twice – I fear the worst seeing the status being “3-Accepted”

You have a point but it’s the developers of MigLayout that wants it to be included in the JDK the most, maybe they feel it’s pretty much complete? I mean, Swing’s one thing but how much further can a LayoutManager really be developed after a certain point?

unfortunately, bugfixes are often not backwards incompatible.

LOL :wink:

[quote=“cylab,post:7,topic:33716”]
Haha, I didn’t notice that. :slight_smile: