View unanswered posts | View active topics It is currently Wed Apr 26, 2017 10:27 pm



Reply to topic  [ 3 posts ] 
 Weird MigLayout (extra space) 
Author Message

Joined: Tue Jun 16, 2009 6:00 pm
Posts: 2
Post Weird MigLayout (extra space)
Hello guys, first off I love MigLayout. It makes it designing in Java so easy!

But now for the first time it doesn't make sense to me. Please have a look at the attached file below the text.

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 my short code:

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");
    }
}


Why is there 7 pixels of space between the borders?


Attachments:
File comment: JPanel with a JTextArea inside, both with a line border. There is space between the borders which shouldn't be there.
weirdMigLayout.png
weirdMigLayout.png [ 682 Bytes | Viewed 9718 times ]
Tue Jun 16, 2009 6:10 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Weird MigLayout (extra space)
Hello,

That is the insets of the panel. They are not present for docks around the dock.

Just add "insets 0" next to "fill".

Btw, I think just center means center aligned, not "dock center". Haven't checked though.

Cheers,
Mikael


Tue Jun 16, 2009 7:47 pm
Profile WWW

Joined: Tue Jun 16, 2009 6:00 pm
Posts: 2
Post Re: Weird MigLayout (extra space)
Thank you very much, that did the trick. Guess I should have read the manual more carefully. I read before in the manual that just writing "center" is a shortcut for "dock center", so I should have picked up the insets thing also...

I think MigLayout is awesome, I hope it's included in JDK 7 - you've got my vote!


Tue Jun 16, 2009 7:55 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.