This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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
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