zapatilla
zapatilla

Reputation: 1843

How can I combine Left to Right and Right to Left text within Java Swing text pane?

I have a text editor that I have written using Java Swing. I'm using a JEditorPane for the text area, and so far it was only needed that text direction was left to right.

I now have to give support to right to left scripture (specifically Arabic scripture), and not only that, the editor needs to support both left to right and right to left scripture within the same file, meaning there will be some lines that are written left to right and some other right to left.

From the docs, I know I can set up the scripture direction on the component level (the JEditorPane), but I need to do it on a per-line basis.

Is there a better Java Swing component to use for this? Is it possible at all to have both scripture directions in a single component?

Upvotes: 0

Views: 125

Answers (1)

Michael Gantman
Michael Gantman

Reputation: 7808

Actually it comes with out of the box support for that. The Editor supports it alrady. The dirrection that you set is an initial direction. When user writes a text (s)he can change direction using keyboard just like in any other editor. It is not perfect but it works. You don't need to do anything

Upvotes: 0

Related Questions