Can i use html with JTextArea?

i try

textArea.setText("<html><b>something</b></html>");

but it only show html code

Can i use html with JTextArea?

thanks.

PS:

another problem: how made JTextarea autoscroll when i append text for it?

Message was edited by:

NhTin

[337 byte] By [NhTina] at [2007-11-26 17:14:48]
# 1
"No" on the HTML.Don't know about autoscrolling... I've never wanted it... but I'd be interested in the answer.Keith.
corlettka at 2007-7-8 23:42:47 > top of Java-index,Desktop,Core GUI APIs...
# 2

i found JEditorPane can show html code,

i try use

JEditorPane editor = new JEditorPane();

editor.setContentType("text/html");

editor.setText("<b>asdasd</b>");

it ok, but when i tried 2 way to append text:

1.

editor.setText(editor.getText()+"<b>asdasd</b>");

2.

String html = editor.getText();

editor.setText(html+"<b>asdasd</b>");

it show a blank screen, nothing on it

how can i do to append text/html to JEditorPane?

thanks

Message was edited by:

NhTin

NhTina at 2007-7-8 23:42:47 > top of Java-index,Desktop,Core GUI APIs...
# 3

Don't know what you exact requirement is, but I find it easier to work with attributes than with HTML:

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

> another problem: how made JTextarea autoscroll when i append text for it?

textComponent.setCaretPosition( textComponent.getDocument().getLength() );

camickra at 2007-7-8 23:42:47 > top of Java-index,Desktop,Core GUI APIs...