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 Force Scrool on JTextPane? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Force Scrool on JTextPane?" Watch "Force Scrool on JTextPane?" New topic

Force Scrool on JTextPane?

Jimmy Nilsson

Joined: Sep 25, 2004
Posts: 26

I have a JTextPane that i have added som text in, this text is to the left, by this i dont get the horizontal scrollbara available.

I am drawing some drwaings in this JTextPane and need to be abled to scrool horizontal to see all the drawings.

How do i do this? i know that JPane have a prefersize witch works fine, but JTextPane does not respond on this method?

How do i solve this?

Joe Ess

Joined: Oct 29, 2001
Posts: 9189

JTextPane does not have scrollbars. You have to use a JScrollPane.

[How To Ask Questions On JavaRanch]
Jimmy Nilsson

Joined: Sep 25, 2004
Posts: 26
Yes i use JScrollbars, exacly as i do to the JPane, but in the jpane i can set the preferedsize and the horizontal jscoolbar will be activated, this does not wokr in JTextPane.

I have tryed before to set values to the JScroolbar but this wount work, maby you could show me?

As i said, i can get the vertical scroolbars active by adding text but to activet the hrozontal whene there is no text simes hard?

I agree. Here's the link:
subject: Force Scrool on JTextPane?
jQuery in Action, 3rd edition