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. 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.