[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] Re: Getting scroll pane to display bottom of text (using Swing)
|
- From: JACK YAO <yaofahua@xxxxxxxxxxx>
- Date: Wed, 19 Oct 2005 20:21:28 +0800
- Newsgroups: eclipse.newcomer
- Organization: Tsinghua Univ
- User-agent: Thunderbird 1.4.1 (Windows/20051006)
Peter:
you needn't use other JScrollPane methods if you only want to display
the lastest text.The following is an example:
**************************************************************
public class test extends JFrame implements ActionListener {
JTextArea ta;
int i = 0;
public test() {
ta = new JTextArea(10,10);
JScrollPane sp = new JScrollPane(ta);
this.add(sp);
JButton btn = new JButton("test");
btn.addActionListener(this);
this.add(btn,BorderLayout.NORTH);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
ta.append("line :"+(i++)+"\n");
}
public static void main(String[] args) {
new test();
}
}
****************************************************************
Hope you will solve your problem.
--
JACK YAO, Beijing, China