JTextArea
의 자동 최소 폭이 언제 설정 그들이 크기를 조정해야하기 때문이다. 자세한 내용은 MigLayout forum에서 확인할 수 있습니다. 대략적으로 요약하려면 JTextArea
을 포함하는 패널을 만들고 크기 조정 동작을 제어하십시오. 여기에 위의 포럼 게시물에서 발췌 한 것입니다 :
static class MyPanel extends JPanel implements Scrollable
{
MyPanel(LayoutManager layout)
{
super(layout);
}
public Dimension getPreferredScrollableViewportSize()
{
return getPreferredSize();
}
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
{
return 0;
}
public boolean getScrollableTracksViewportHeight()
{
return false;
}
public boolean getScrollableTracksViewportWidth()
{
return true;
}
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
{
return 0;
}
}
그런 다음 당신은 JTextArea에를 사용하는 것이 어디든지, 텍스트 영역이 포함 된 패널을 사용하여 :
MigLayout thisLayout = new MigLayout("", "[][grow]", "[]20[]");
this.setLayout(thisLayout);
{
jLabel1 = new JLabel();
this.add(jLabel1, "cell 0 0");
jLabel1.setText("jLabel1");
}
{
JPanel textAreaPanel = new MyPanel(new MigLayout("wrap", "[grow,fill]", "[]"));
jTextArea1 = new JTextArea();
textAreaPanel.add(jTextArea1);
this.add(textAreaPanel, "cell 0 1 2 1,grow,wmin 10");
jTextArea1.setText("jTextArea1");
jTextArea1.setLineWrap(false);
}
간단하고 빠른 솔루션 당신이 여기 찾을 수 있습니다! http://stackoverflow.com/a/7833439/2530822 – TotoliciCristian