文本区域右侧的Java显示文本

我在ComponentOrientation.RIGHT_TO_LEFT的问题是’/’或’!’等字符 要么 ‘。’ 显示在左侧。

我只需要从右到左绘制文本,但使用标准,西方,英文从左到右的符号表示文本字符。

这可能无需手动渲染文本吗?

我无法生成您的问题,请您使用我的SSCCE左侧显示。

在此处输入图像描述

来自代码

 import java.awt.ComponentOrientation; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; 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(); } JTextArea text = new JTextArea(10, 5); text.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); text.setText("one/\n " + "!two\n" + ".three\n" + "/four\n" + "five!\n" + "six.\n" + "seven\n" + "eight\n"); JScrollPane pane = new JScrollPane(text); JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("العنوان بالعربي"); frame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); frame.add(pane); frame.pack(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } }); } } 

尝试为文本字段调用setAlignmentX(Component.RIGHT_ALIGNMENT)