File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Scrolling a JTextPane within a JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Scrolling a JTextPane within a JScrollPane" Watch "Scrolling a JTextPane within a JScrollPane" New topic

Scrolling a JTextPane within a JScrollPane

Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I have a problem which seems so elementary that I'm embarrassed to bring it up, but I can't find the solution through the javadocs or my other resources.

I have a JTextPane which I am using to display data, output only. I am placing it in a JScrollPane. What I want to do is have it scroll to the bottom when I add text to it. Manually setting the vertical scroll bar to its maximum value doesn't seem to work.

Can anyone help me with this?

Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
You may try to work with the viewport.
Check this:

Charles.<br />(SCJD2)
I agree. Here's the link:
subject: Scrolling a JTextPane within a JScrollPane
Similar Threads
Continues Characters in JTextPane
ScrollPane behave differently
Question about component sizes
JTextPane: scrolling with mouse wheel
JScrollPane: Auto-Scroll as Text is entered into the JTextComponent it is bound to