public class DailogDemo
{
private JDialog chatdailog;
private JTextArea chatHistory;
private JScrollPane mScrollMessage;
DailogDemo()
{
chatdailog=new JDialog();
chatdailog.setSize(300, 400);
chatHistory=new JTextArea();
chatHistory.setPreferredSize(new Dimension(150,100));
mScrollMessage=new JScrollPane();
mScrollMessage.add(chatHistory);
mScrollMessage.setBounds(4, 10, 150, 100);
mScrollMessage.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
chatdailog.add(mScrollMessage);
chatdailog.show();
}
public static void main(String args[])
{
new DailogDemo();
}
}
在上面的代碼中,我無法看到JScrollPane中的JTextArea。有人知道我做錯了什麼嗎?爲JTextArea的將帶有JTextArea的JScrollPane添加到JDailog中
chatHistory.setSize(new Dimension(width,height));
謝謝mK orbel ... – 2012-07-26 09:40:38