[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)

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