1
我有下面的代碼:力的JTextArea到JScrollPane的底部
public class LobbyView extends JPanel
{
this.setLayout(new MigLayout());
private final JTextArea chatWindowMessage = new JTextArea();
private final JScrollPane chatWindow = new JScrollPane(chatWindowMessage);
LobbyView(Window sentWindow)
{
chatWindow.setViewportView(chatWindowMessage);
chatWindow.setPreferredSize(new Dimension(300, 300));
chatWindow.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
chatWindowMessage.setLineWrap(true);
chatWindowMessage.append("test" + "\n");
chatWindowMessage.append("test 2" + "\n");
this.add(chatWindow, "pos 180px 75px");
this.add(chatMessage, "pos 180px 380px");
}
}
的代碼導致以下JScrollPane中:
如何強制JTextArea中來JScrollPane的底部,所以它看起來是這樣的(注:我使用MigLayout):
的borderlayout的文本區域和所有其餘嵌套的borderlayout中心是很酷? –
可能重複[如何更改一個JTextArea文本的位置(http://stackoverflow.com/questions/16800125/how-to-change-the-texts-position-in-a-jtextarea) – Reimeus