Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane without text  RSS feed

Paulo Faria
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a non inicialized JTextPane, and want to do a simple pagination algorithm on it for perfomance reasons.

I'm thinking:
To inicialize the text i have a position counter that keeps the position in the original document of the displayed text, and when i request a new text, i have to display from position to position (+/-) minimum chars to fill the space.

Then i'm thinking of using the TextComponent viewToModel method to update the position counter.

The minimum char value would be updated in a TextResizeListener extends ComponentAdapter, probably.

My problems are these:

How can i calculate a decent minimum chars value that assures that the "paginated" text completly fills the viewport?

The methods that rip the text from a styleddocument are inherited from document and don't have style information associated. Since i want to display parsed styled text this is a problem.

I want the interface to be resisable, but i dont want the lines of the text to be cut horizontaly, at the begining or end (like all JTextComponents cut it). I am kinda lost in these issues.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!