?
Solved

Limit JTextPane size

Posted on 2003-03-20
8
Medium Priority
?
1,753 Views
Last Modified: 2007-12-19
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
Comment
Question by:etgaroy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Expert Comment

by:glottis
ID: 8179149
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
 

Author Comment

by:etgaroy
ID: 8179264
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
 
LVL 2

Expert Comment

by:glottis
ID: 8183507
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Accepted Solution

by:
etgaroy earned 0 total points
ID: 8189245
Thank you glottis.
I have solved the problem using DefaultStyledDocument by manipulating the caret location on the JTextPane.
edgar
0
 
LVL 2

Expert Comment

by:glottis
ID: 8190892
hmmm...
thats is a good solution...
give the points for your own self
0
 

Expert Comment

by:CleanupPing
ID: 9058579
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9727431
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question