• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1765
  • Last Modified:

Limit JTextPane size

Hi,
I want to use a JTextPena for writing but I want to limit the size of the writable area.
Lets say I want to allow writing only in 3 rows. Anything over 3 rows will beep and not be written.
Do I have to use DefaultStyledDocument? and if so how?
thanks,
Edgar
0
etgaroy
Asked:
etgaroy
1 Solution
 
glottisCommented:
only and only 3 rows ? is the user writing continusly in 3 rows or he is pressing enter to go to the next row ?

implementing limitation of how many characters the user can type would be easy :P
0
 
etgaroyAuthor Commented:
Hi glottis,
To limit the number of characters is easy as you said and I can do it using DocumentFilter class.
The problem is that I want to limit the JTextPane to a set number of lines (not necesarily lines seperated by pressing enter). Another problem is that I am using different types of font and font size.
Thanks,
Edgar
0
 
glottisCommented:
u have to look deeply in the textpane class and see how Java inserts string on new lines. maybe that way u can limit.
ill see into this and post if any thing comes up.

interesting challenge here :P
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
etgaroyAuthor Commented:
Thank you glottis.
I have solved the problem using DefaultStyledDocument by manipulating the caret location on the JTextPane.
edgar
0
 
glottisCommented:
hmmm...
thats is a good solution...
give the points for your own self
0
 
CleanupPingCommented:
etgaroy:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
jimmackCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ - refund points

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now