JTextAre 文字右对齐 JTextArea دىكى خەتلەرنى ئوڭدىن س...

直接贴代码了, 自己一看就明白的。

تولا سۆزلەپ ئولتۇرماي كودنىلا چاپلاي. مەنچە بىر كۆرۈپلا چۈشىنەلەيسىز.

import java.awt.ComponentOrientation;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class RTLTextArea extends JPanel {

    private static final String s = "ئۇيغۇرچە";
    private JTextArea jta = new JTextArea(7, 5);
    private Locale arabic = new Locale("ar", "KW");
    private ComponentOrientation arabicOrientation =
        ComponentOrientation.getOrientation(arabic);

    public RTLTextArea() {
        this.setLayout(new GridLayout());
        this.add(new JScrollPane(jta));
        this.applyComponentOrientation(arabicOrientation);
        for (int i = 0; i < 8; i++) {
            jta.append(s + "\n");
        }
    }

    private void display() {
        JFrame f = new JFrame("RTLTextAre");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(this);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new RTLTextArea().display();
            }
        });
    }
}

你可能感兴趣的:(JTextAre 文字右对齐 JTextArea دىكى خەتلەرنى ئوڭدىن س...)