Link to home
Start Free TrialLog in
Avatar of etgaroy
etgaroy

asked on

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
Avatar of glottis
glottis
Flag of Pakistan image

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
Avatar of etgaroy
etgaroy

ASKER

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
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
ASKER CERTIFIED SOLUTION
Avatar of etgaroy
etgaroy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmmm...
thats is a good solution...
give the points for your own self
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.
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