• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextPane problem

 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I was wondering if someone knows the answer to this problem that is driving me crazy. I have defined a JTextPane to be a specific size. The JTextPane itself has no scrollbars so that's not the problem. When I reach the end of a line word wrapping occurs. That's okay. But when I reach the very last line of my JTextPane, I can still keep typing text. Why does this happen? I defined the JTextPane a specific size with .setSize(), and I don't want users to type in more text than the size of the JTextPane itself. You may think that the extra text is no problem since no one can see it but I save this text, and the extra text is getting saved. Any ideas? And why is this occuring in the first place that I can type in more text than the JTextPane size I define.
Joe Crew
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you set the size of the TextArea you are only setting the visible borders of the textarea. The editable area extends well passed the borders you have specified.
You probably need to look into using the BreakIterator method to stop the user from being able to type.
------------------
Happy Coding,
Gregg Bolinger
 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
Thanks for your reply. I figured as much that setSize only controls what is viewable not the text limits. I could not find BreakIterator in the environment I have to use (jdk118 with swing111 - os restrictions) so I had to come up with some else that ended up working fine.
Thanks,
Joe Crew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic