JEditorPane always scrolls down to the bottom, how can I prevent this?

Hello, I have the following code that contains a JTable and JEditorPane in a panel. When I click on a headline on the table, I have some text showing up in the lower pane. My problem is that the lower pane (that is inside a JScrollPane) always scrolls down to the end of the text, but I want to to always point to the beginning.
Does anyone know how to do this?
Your help will be appreciated.
Thanks!
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
public class MyHTMLPaneTest {
     JFrame frame;
     JPanel panel;
     JSplitPane splitPane;
     JTable table;
     JEditorPane htmlPane;
     JPanel tablePanel;
     DefaultTableModel model;
     JViewport viewPort;
     public MyHTMLPaneTest()
          frame = new JFrame("MyCalHTMLPane Test");
          panel = new JPanel(new BorderLayout());
          splitPane = new JSplitPane();
          tablePanel = new JPanel(new BorderLayout());
          setTable();
          tablePanel.add(table.getTableHeader(), BorderLayout.NORTH);
          tablePanel.add(table, BorderLayout.CENTER);
          htmlPane = new HTMLPane();
          JScrollPane pane = new JScrollPane(htmlPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
          viewPort = pane.getViewport();
          viewPort.setViewPosition(new Point(0, 0));
          splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tablePanel, pane);
        panel.add(splitPane, BorderLayout.CENTER);
          frame.getContentPane().add(panel);
          frame.setSize(new Dimension(400, 300));
          frame.setVisible(true);
     public void setTable()
          String[] columnNames = {"Date","Time","Subject"};
         Object[][] data =
              {"03/31/05", "8:20 AM EDT", "Headline 1"},
              {"08/24/05", "8:19 AM EDT", "Headline 2"},
              {"08/18/05", "8:18 AM EDT", "Headline 3"},
             {"08/12/05", "8:17 AM EDT", "Headline 4"},
             {"06/20/05", "8:16 AM EDT", "Headline 5"},
             {"06/20/05", "8:15 AM EDT", "Headline 6"}
         model = new DefaultTableModel(data, columnNames);
         table = new JTable(model);
         table.getSelectionModel().addListSelectionListener(new ListSelectionListener()
             public void valueChanged(ListSelectionEvent e)
                  String text = "LOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOOOOOOONG" +
                            "\nLOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOONG"+
                            "\nLOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG"+
                            "\nSTRIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIIING"+
                            "LOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOOOOOOONG" +
                            "\nLOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOONG"+
                            "\nLOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOO" +
                            "\nOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG"+
                            "\nSTRIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIII" +
                            "\nIIIIIIIIIIIIIIIIIIIIING";
                  htmlPane.setText(text);
     public static void main(String[] args) {
          MyHTMLPaneTest test = new MyHTMLPaneTest();
}

try setCaretPosition:
        table.getSelectionModel().addListSelectionListener(
                new ListSelectionListener()
                    public void valueChanged(ListSelectionEvent e)
                        String text = "LOOOOOOOOOOOOOOOOOOO"
                                + "\nOOOOOOOOOOOO"
                                + "\nOOOOOOOOOOOOOOOO"
                                + "\nOOOOOOOOOOOOOOOO"
                                + "\nIIIIIIIIIIIIIIIIIIIII"
                                + "\nIIIIIIIIIIIIIIIIIIIIING";
                        htmlPane.setText(text);
                        htmlPane.setCaretPosition(0);  // ******* here **********
                });

Similar Messages

Maybe you are looking for

  • Authorization problems after upgrade

    After upgrading to the new version of iTunes, I was prompted to reauthorize my pc. It will not accept my old aol screename and password (no longer with aol), and when I created a new screename with apple, it did not copy 410 songs over. So I'm stuck.

  • WRT54GS v6 Firmware Wireless keeps going up/down

    I've read a similar thread and wondering if anyone has found a resolution to this issue. Seems like others are experiencing this issue with 7.x firmware also.  I've had this issue for a year and cannot accept this. I've found the solution. " Apple Ai

  • IBook not connecting to Airport

    Hi I have an iBook 13' I am very happy with it, but I have always been afflicted by a problem, every time my iBook goes to sleep, it loses the ability to connect to my Airport. When i wake or start it, it show a list of wifi connections, all my neigh

  • Business Area for VAT Accounts

    Hi, Please anyone can explain how to post business area at the time of doing invoice verification if one company using multiple business area.Also this company is using one plant as well as one company code. According to my knowledge business area ca

  • QuickTime stutters only with .mpg files

    Only since I've updated to Mac OS X 10.5.2 that I've been experiencing this problem. I have a load of .mpg files recorded using my digital camera, as well as a bunch of files I've downloaded from the net. These used to play back perfectly fine and sm