A
A
Anton @ Lyalin2017-03-06 09:31:24
Java
Anton @ Lyalin, 2017-03-06 09:31:24

Why does it jump to the end of text when outputting to JEditorPane?

When displaying text, the skrullbar rolls to the end of the text, how can I make sure that nothing changes? More precisely, to show exactly the beginning of the text?501d123a5d084f1baea281d8c0c8b16d.png

JEditorPane jEditorPane = new JEditorPane();
        jEditorPane.setContentType("text/html");
        jEditorPane.setFont(new Font("Arial", Font.PLAIN, 14));

        JEditorPane jEditorPane1 = new JEditorPane();
        jEditorPane1.setContentType("text/html");
        jEditorPane1.setFont(new Font("Arial", Font.PLAIN, 14));

        jEditorPane.setText(text);

        JScrollPane jScrollPane = new JScrollPane(jEditorPane);
        jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane.setPreferredSize(new Dimension(580, 620));

        JScrollPane jScrollPane1 = new JScrollPane(jEditorPane1);
        jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setPreferredSize(new Dimension(580, 620));

        jPanelStart.add(jScrollPane);
        jPanelEnd.add(jScrollPane1);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2017-03-06
@jamakasi666

After uploading the text
jEditorPane.setCaretPosition(тут догадаешься=) );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question