Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Gerald Lampi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!