html - how to get unicode text from jtextpane java -
i have set jtextpane content type html , setted
ta_description = new jtextpane(); ta_description.setcontenttype("text/html"); ta_description.setfont(new font("latha", font.plain, 12)); ta_description.settext("<![cdata[<br>வேலூர் மாவட்டம், அணைக்கட்டு தொகுதி பா.ம.க.வை சேர்ந்த கலையரசு எம்.எல்.ஏ. நேற்று முன்தினம் காலை முதல்-அமைச்சர் ஜெயலலிதாவை சந்தித்து தனது தொகுதி பிரச்சினைகள் குறித்து பேசினார். அதைத்தொடர்ந்து அவரை கட்சியில் இருந்து நீக்குவதாக பா.ம.க. தலைவர் ஜி.கே.மணி அறிவித்தார்.<br>]]>);
when text using ta_description.gettext() , below
<![cdata[<html> <head>
</head> <body> <br> வேலூர் மாவட்டம், அணைக்கட்டு தொகுதி பா.ம.க.வை சேர்ந்த கலையரசு எம்.எல்.ஏ. நேற்று முன்தினம் காலை முதல்-அமைச்சர் ஜெயலலிதாவை சந்தித்து தனது தொகுதி பிரச்சினைகள் குறித்து பேசினார். அதைத்தொடர்ந்து அவரை கட்சியில் இருந்து நீக்குவதாக பா.ம.க. தலைவர் ஜி.கே.மணி அறிவித்தார்.<br> </body> </html> ]]>
i saw tamil unicode characters http://www.utf.ru/tables/tamil.html
i need text correctly , dono how text properly.
java uses font system , if system doesn't contain specific font can deploy font within application using font.createfont(). if donot have tamil font download here
first thing have tamil unicode supported font. somthing this:
font tamil =new font("latha", font.bold,15);//i had font latha supports tamil font
then set font of jtextpane :
ta_description.setfont(tamil);
full code:
import java.awt.borderlayout; import java.awt.eventqueue; import java.awt.font; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.jtextpane; import javax.swing.border.emptyborder; public class test extends jframe { private jpanel contentpane; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { test frame = new test(); frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } /** * create frame. */ public test() { setdefaultcloseoperation(jframe.exit_on_close); setbounds(100, 100, 450, 300); contentpane = new jpanel(); contentpane.setborder(new emptyborder(5, 5, 5, 5)); contentpane.setlayout(new borderlayout(0, 0)); setcontentpane(contentpane); jtextpane textpane = new jtextpane(); contentpane.add(textpane, borderlayout.center); font tamilfont=new font("latha", font.bold,15); textpane.setfont(tamilfont); } }
Comments
Post a Comment