aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Why does this JTextPane cause JScrollPane to flicker when I type into it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why does this JTextPane cause JScrollPane to flicker when I type into it?" Watch "Why does this JTextPane cause JScrollPane to flicker when I type into it?" New topic
Author

Why does this JTextPane cause JScrollPane to flicker when I type into it?

Gerald Lampi
Greenhorn

Joined: Sep 11, 2009
Posts: 2
The following code example causes the vertical scrollbar to appear and disappear as you type into the JTextPane.

Any ideas on how to fix it?

Screencast of the flicker issue.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
First of all it works OK with a JTextArea.

Why the difference? I'm just guessing.

In both cases the text components have a variable preferred size. As characters are added/removed the preferred size changes and the component is revalidated.

For a text pane the text wraps automatically (when needed), for the text area it doesn't.

Maybe the text pane has a problem thinking it needs to wrap the text but then realizes it doesn't so the scrollbar flashes.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Gerald, we don't have too many rules here, but we do ask that you BeForthrightWhenCrossPostingToOtherSites

http://forums.oracle.com/forums/thread.jspa?threadID=2264353


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does this JTextPane cause JScrollPane to flicker when I type into it?