Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display html formatted text in text area of java application?

I am scraping data from web site using my java application and want to display the result after parsing code of html page in a Text Area made in Swing.

Text like: hello <b>every</b>one should be displayed as: 'hello everyone' in text area. Thanks!!

like image 715
Deepak Yadav Avatar asked Mar 14 '10 08:03

Deepak Yadav


2 Answers

JEditorPane ep = new JEditorPane();
ep.setContentType("text/html");
ep.setText("html code");
like image 197
Omar Jaber Avatar answered Sep 18 '22 02:09

Omar Jaber


You can use a JEditorPane to display HTML or a JTextPane, which allows you to set attributes for specific characters. Read the API and you will find a link to the Swing tutorial which provides examples.

like image 31
camickr Avatar answered Sep 22 '22 02:09

camickr