Hello!
I can't understand why the m_scrollPane (see code below) is auto scroll to
end while adding JTextArea.
//---- start
import javax.swing.*;
import java.awt.*;
public class Main
{
public static JFrame m_mainFrame;
public static JPanel m_panel = new JPanel();
public static JScrollPane m_scrollPane;
public static Dimension m_size = new Dimension(200, 300);
public static void fill()
{
JTextArea text;
m_panel.removeAll();
for(int i = 0; i < 100; i ++) {
text = new JTextArea("Text");
text.setLineWrap(true);
text.setWrapStyleWord(true);
text.setEditable(false);
m_panel.add(text);
}
m_mainFrame.validate();
m_mainFrame.repaint();
}
public static void main(String args[])
{
m_mainFrame = new JFrame();
m_mainFrame.setSize(m_size);
m_mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_mainFrame.show();
m_panel.setLayout(new BoxLayout(m_panel, BoxLayout.Y_AXIS));
m_scrollPane = new JScrollPane(m_panel);
m_mainFrame.getContentPane().add(m_scrollPane, BorderLayout.CENTER);
// if easy call fill() then it don't scroll to end
// but if call hapens from another thread then it scroll to end
SwingUtilities.invokeLater(new Runnable(){
public void run() {
fill();
}
});
}
}
//---- end
What wrong?
Onopin Mikhail.([EMAIL PROTECTED])
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing