JTextPane limited lines.

Dear sir;

How will i restrict the line number of JtextPane?

but i got line count of JtextPane.

the code is avaible here.

public static int getWrappedLines(JTextPane component)

{

int lines = 0;

View view = component.getUI().getRootView(component).getView(0);

int paragraphs = view.getViewCount();

for (int i = 0; i < paragraphs; i++)

{

lines += view.getView(i).getViewCount();

}

return lines;

in my case After three lines JTextpane wont allow to edit charactor.

But it should allow to delete whatever i typed it up to three lines.

please give the solution for the same

[673 byte] By [uvariSubasha] at [2007-10-3 9:45:59]
# 1
You where asked in your other posting to use the "Code" formatting tags so the code would be readable.
camickra at 2007-7-15 5:02:44 > top of Java-index,Desktop,Core GUI APIs...
# 2

Dear friend

public static int getWrappedLines(JTextPane component)

{

int lines = 0;

View view = component.getUI().getRootView(component).getView(0);

int paragraphs = view.getViewCount();

for (int i = 0; i < paragraphs; i++)

{

lines += view.getView(i).getViewCount();

}

Code is avaiable here.

if u want any thing please ask me

uvariSubasha at 2007-7-15 5:02:44 > top of Java-index,Desktop,Core GUI APIs...
# 3

Did you use the "Preview" button to look at your code? You have to post your original code so it retains the formatting. Make an effort to learn how to use the forum correctly.

If I understand the question then this posting should have a solution:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=689486

Actually, I doubt the above is what you need so check out my answer in this posting instead for a different idea:

http://forum.java.sun.com/thread.jspa?messageID=4464970

camickra at 2007-7-15 5:02:44 > top of Java-index,Desktop,Core GUI APIs...
# 4

> Did you use the "Preview" button to look at your

> code? You have to post your original code so it

> retains the formatting. Make an effort to learn how

> to use the forum correctly.

>

> If I understand the question then this posting should

> have a solution:

>

> http://forum.java.sun.com/thread.jspa?forumID=57&threa

> dID=689486

>

> Actually, I doubt the above is what you need so check

> out my answer in this posting instead for a different

> idea:

>

> http://forum.java.sun.com/thread.jspa?messageID=446497

I am using JTextPane.But it is for JtextArea

uvariSubasha at 2007-7-15 5:02:44 > top of Java-index,Desktop,Core GUI APIs...
# 5
> I am using JTextPane.But it is for JtextArea A DocumentListener or DocumentFilter can be added to any JTextComponent.
camickra at 2007-7-15 5:02:44 > top of Java-index,Desktop,Core GUI APIs...