Texto multilinhas com html

2 respostas
G

Olá pessoal, estou precisando de um componente de texto editável multilinhas que aceite código html.

Tentei fazer com o JTextArea, mas não funcionou, as tags aparecem no texto, elas não são convertidas em formatações diferentes (cor, tamanho, etc):

JTextArea textArea = new JTextArea();
textArea.setText("<html><b>teste</b></html>");

Alguém poderia me ajudar?

2 Respostas

douglaskd

isso te ajuda?

http://shef.sourceforge.net/

JFrame frame = new JFrame(); HTMLEditorPane editor = new HTMLEditorPane(); frame.add(editor);

G

douglaskd:
isso te ajuda?

http://shef.sourceforge.net/

JFrame frame = new JFrame(); HTMLEditorPane editor = new HTMLEditorPane(); frame.add(editor);

É que não posso utilizar bibliotecas externas. Mas já consegui fazer o que queria. Fiz da seguinte forma:

JTextPane textPane = new JTextPane(); textPane.setContentType("text/html"); textPane.setText("<html><b>teste</b></html>");

O segredo estava no setContentType. Obrigado pela ajuda cara. =D

Criado 27 de março de 2012
Ultima resposta 28 de mar. de 2012
Respostas 2
Participantes 2