retrieving data from JTextPane

Hi Forum,

I want to get data from JTextPane i an using

tpAllMessages.getDocument().getText(tpAllMessages.getSelectionStart(),tpAllMessages.getSelectionEnd());

and

tpAllMessages.getText();

but it is not working throwing badlocation exception.

if you can help,

thanx

[313 byte] By [p_more_javaa] at [2007-11-26 17:43:34]
# 1

> but it is not working throwing badlocation exception.

Then fix your offsets.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-9 0:11:45 > top of Java-index,Desktop,Core GUI APIs...
# 2
I think there might not be anything selected in your JTextPane when you are trying to call that function, hence BadLocation error will be thrown.Also if there is no text...
DhruvaSagara at 2007-7-9 0:11:45 > top of Java-index,Desktop,Core GUI APIs...
# 3
thanx i am with solution,
p_more_javaa at 2007-7-9 0:11:45 > top of Java-index,Desktop,Core GUI APIs...