-
Bug
-
Resolution: Unresolved
-
P4
-
21.0.7-oracle
-
x86_64
-
os_x
ADDITIONAL SYSTEM INFORMATION :
Darwin Kernel Version 23.6.0: Thu Apr 24 20:31:17 PDT 2025; root:xnu-10063.141.1.705.2~1/RELEASE_ARM64_T8112 arm64
A DESCRIPTION OF THE PROBLEM :
On macOS, selecting RTL text in a JEditorPane with HTML content, line wrapping, and a non-Aqua Look and Feel causes corrupted or unreadable selection rendering starting from line 2 and below.
This issue occurs only when all of the following are true:
- JEditorPane has text/html content
- Component orientation is RIGHT_TO_LEFT
- Word wrapping is active (via fixed CSS width)
- Non-Aqua Look and Feel is used (e.g. MetalLookAndFeel)
- editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false) is set
- For some font styles and sizes
The issue does not occur on line 1 — only when selecting text starting from line 2 or lower.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the program below on macOS.
2. Use the mouse to select any word on the second or later line of the displayed text.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selected text is clearly highlighted without corruption or modification.
ACTUAL -
Different (wrong) characters are displayed in the selected area. The selection does not reflect the actual content — it appears visually corrupted, with characters from other positions or unrelated glyphs.
---------- BEGIN SOURCE ----------
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 HtmlViewerApp {
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> اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو</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);
}
});
}
}
---------- END SOURCE ----------
Darwin Kernel Version 23.6.0: Thu Apr 24 20:31:17 PDT 2025; root:xnu-10063.141.1.705.2~1/RELEASE_ARM64_T8112 arm64
A DESCRIPTION OF THE PROBLEM :
On macOS, selecting RTL text in a JEditorPane with HTML content, line wrapping, and a non-Aqua Look and Feel causes corrupted or unreadable selection rendering starting from line 2 and below.
This issue occurs only when all of the following are true:
- JEditorPane has text/html content
- Component orientation is RIGHT_TO_LEFT
- Word wrapping is active (via fixed CSS width)
- Non-Aqua Look and Feel is used (e.g. MetalLookAndFeel)
- editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false) is set
- For some font styles and sizes
The issue does not occur on line 1 — only when selecting text starting from line 2 or lower.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the program below on macOS.
2. Use the mouse to select any word on the second or later line of the displayed text.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selected text is clearly highlighted without corruption or modification.
ACTUAL -
Different (wrong) characters are displayed in the selected area. The selection does not reflect the actual content — it appears visually corrupted, with characters from other positions or unrelated glyphs.
---------- BEGIN SOURCE ----------
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 HtmlViewerApp {
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> اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو اااا دددد رررر وووو</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);
}
});
}
}
---------- END SOURCE ----------