Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do i clear/empty JTextPane?

2,739 views
Skip to first unread message

Jayesh Patel

unread,
May 15, 2003, 8:30:16 AM5/15/03
to
Hello

We've got a log pane showing log entries generated
from our application. As you can image
it gets very full.

Is there any way that we can clear the logs,
basically empty the pane?

We're using an instance of JTextPane added to a
JScrollPane.

Anybody, got any ideas?

Many thanks.

jay


K.Koper

unread,
May 15, 2003, 10:00:32 AM5/15/03
to
didn't try it but from the top of my head

textPane.setDocument(new PlainDocument());

should work

K.

Christina Robertson

unread,
May 15, 2003, 10:28:09 AM5/15/03
to
Have you tried textPane.setText("")?

Maybe I'm not reading your question correctly but setting the text its
displaying to empty will do what I think you need.

--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Christina Robertson - Research Engineer
Oasis Advanced Engineering, Inc.
Phone 248-373-9800 x 236
Fax 248-373-9898

Jon A. Cruz

unread,
May 15, 2003, 10:37:19 AM5/15/03
to
Jayesh Patel wrote:
> Is there any way that we can clear the logs,
> basically empty the pane?
>
> We're using an instance of JTextPane added to a
> JScrollPane.
>
> Anybody, got any ideas?


myLogTextPane.setText("");

Fred L. Kleinschmidt

unread,
May 15, 2003, 10:46:26 AM5/15/03
to Jayesh Patel

You could just call:
log.setText("");
See the discussion on the setText() method of JEditorPane.
--
Fred L. Kleinschmidt
Associate Technical Fellow
Boeing Common User Interface Services

Jayesh Patel

unread,
May 15, 2003, 6:25:57 PM5/15/03
to
I've tried both these methods but to no avail.

Would I be better of deleting the pane and adding
a new instance?

jay

"Christina Robertson"
<robe...@OasisAdvancedEngineering.com> wrote in
message
news:3EC3A3F9...@OasisAdvancedEngineering.co
m...

Jon A. Cruz

unread,
May 16, 2003, 1:00:46 AM5/16/03
to
Jayesh Patel wrote:
> I've tried both these methods but to no avail.
>
> Would I be better of deleting the pane and adding
> a new instance?

Probably not.

Instead figure out why things aren't working for you.

first, toss a few calls to the pane's parent

invalidate();
revalidate();


That might do it.


Otherwise...

It could very easily be that you aren't holding the reference to the
instance you think you are.

0 new messages