This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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: 2787
12
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!