вы можете попробовать что-то вроде JTextPane, а не JTextArea
JTextPane textPane = new JTextPane();
SimpleAttributeSet attributes = new SimpleAttributeSet();
StyleConstants.setAlignment(attributes, StyleConstants.ALIGN_RIGHT);
textPane.setParagraphAttributes(attributes, true);
, если вы хотите использовать JTextArea, тогда вам нужно добавить в scrollpane, и тогда scorllpane будет частью Panel, пожалуйста, попробуйте ниже код
JTextArea text = new JTextArea(-, -);
JScrollPane sPane = new JScrollPane( text );
JPanel panel = new JPanel();
panel.add( sPane );
sPane.addAncestorListener( new AncestorListener()
{
public void ancestorAdded(AncestorEvent e)
{
JScrollPane sPane = (JScrollPane)e.getComponent();
sPane.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
}
});
надеюсь, что это сработает для вас