It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes JTextPane problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextPane problem" Watch "JTextPane problem" New topic
Author

JTextPane problem

Joe Crew
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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


GenRocket - Experts at Building Test Data
Joe Crew
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextPane problem