to 3- display it in my text component that is JTextPane
Wikipedia source
Project Encoded in Simple UTF-8
import javax.swing.*; import java.awt.*; public class Example { private JFrame frameA = new JFrame("Example"); private JTextArea textA = new JTextArea(10, 5); public Example() { frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); textA.setForeground(new Color(255, 150, 150)); textA.setText("Peace be upon you (Hello) - السلام علیکم " + "\n"); textA.append("Peace be upon you too (Hello) - و علیکم السلام " + "\n"); textA.append("I am happy to meet you - آپ سے مل کر خوشی ہوئی" + "\n"); textA.append("Do you speak English? - کیا آپ انگریزی بولتے ہیں؟" + "\n"); frameA.add(textA); frameA.pack(); frameA.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Example exam = new Example(); } }); } }
EDIT:
thanks stas
by mistake I put this on JTextArea
added JTextPane example
import javax.swing.*; import java.awt.*; public class Example { private JFrame frameA = new JFrame("Example"); private JTextPane textP = new JTextPane(); public Example() { frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); textP.setForeground(new Color(255, 150, 150)); textP.setText("Peace be upon you (Hello) - السلام علیکم " + "\n" +"Peace be upon you too (Hello) - و علیکم السلام " + "\n" +"I am happy to meet you - آپ سے مل کر خوشی ہوئی" + "\n" +"Do you speak English? - کیا آپ انگریزی بولتے ہیں؟" + "\n"); frameA.add(textP); frameA.pack(); frameA.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Example exam = new Example(); } }); } }
source share