タグの意味ですかdir="rtl"
BugParade コードに基づいて、JLabel
またはを直接使用することはできませんJTextArea
import java.awt.ComponentOrientation;
import java.awt.GridLayout;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.UIManager;
public class RightToLeft {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
String str =("<html > <head> <title>Test</title> <style> </style> </head> <body> <div align=right>"
+ " <p><b><font face=Arial color=#5078A8><span lang=he>Hebrew Test</span></font></b></p> "
+ "<p><span lang=he><font face=Arial size=2> HTML Table</font></span></p> <table dir =rtl "
+ "border=1 cellpadding=10 width=62% id=AutoNumber1 bordercolorlight=#FFFFFF bordercolordark=#FFFFFF> "
+ "<tr> <td width=28% valign=top bgcolor=#D0E4F8 class=cellclass><font face=Arial size=2 "
+ "color=#687C98><b>1 2 3</b></font></td><td width=72% valign=top bgcolor=#D0E4F8 dir=rtl> "
+ "<font face=Arial size=2><span lang=he>2</span></font></td> </tr> <tr> "
+ "<td width=28% valign=top bgcolor=#F8F8FF style=color #687C98><b> <font face=Arial size=2>"
+ "<span lang=he>3</span></font></b></td> <td width=72% align=right valign=top bgcolor=#F8F8FF> "
+ "<font face=Arial size=2><span lang=he>4</span></font></td> </tr> <tr> "
+ "<td width=28% valign=top bgcolor=#D0E4F8> <font face=Arial size=2 color=#687C98><b>5</b>"
+ "</font></td> <td width=72% align=right valign=top bgcolor=#D0E4F8> <font face=Arial size=2>"
+ "<span lang=he>6 </span></font></td> </tr> <tr> <td width=28%>LEFT </td> "
+ "<td width=72%>RIGHT </td> </tr> </table> </div> </body> </html> ");
JTextPane text = new JTextPane();
text.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
text.setContentType("text/html");
text.setText(str);
JScrollPane pane = new JScrollPane(text);
JEditorPane text1 = new JEditorPane();
text1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
text1.setContentType("text/html");
text1.setText(str);
JScrollPane pane1 = new JScrollPane(text1);
JLabel text2 = new JLabel();
text2.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
//text2.setContentType("text/html"); // not implemented
text2.setText(str);
JScrollPane pane2 = new JScrollPane(text2);
JTextArea text3 = new JTextArea();
text3.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
//text3.setContentType("text/html"); // not implemented
text3.setText(str);
JScrollPane pane3 = new JScrollPane(text3);
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("العنوان بالعربي");
frame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
frame.setLayout(new GridLayout(2,2,5,5));
frame.add(pane);
frame.add(pane1);
frame.add(pane2);
frame.add(pane3);
//frame.pack();
frame.setSize(400,600);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
}
}