• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTextPane problem

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic