import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Font;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;

public class Test {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
             try {
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
} catch (Exception e) {
throw new RuntimeException(e);
}
                JFrame frame = new JFrame("JEditorPane RTL Demo");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                JEditorPane editorPane = new JEditorPane();
                String html = "<html><body><p>&nbsp;اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو</p></body></html>";
                editorPane.setOpaque(false);
                editorPane.setContentType("text/html");
                editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
                editorPane.setFont(new Font("SansSerif", Font.BOLD, 9));
                final HTMLDocument document = (HTMLDocument) editorPane.getDocument();
         final StyleSheet styleSheet = document.getStyleSheet();
         StyleSheet ownStyleSheet = new StyleSheet();
         ownStyleSheet.addRule("body { font-family: \"SansSerif\"; font-size: 9pt; font-weight: bold;}");
         styleSheet.addStyleSheet(ownStyleSheet);
         document.getStyleSheet().addRule("body { width: 94}");
                editorPane.setEditable(false);
                editorPane.setText(html);
                editorPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
                final Container content = frame.getContentPane();
content.add(editorPane, BorderLayout.CENTER);
                frame.pack();
                frame.setVisible(true);
            }
        });
    }
}