-
Bug
-
Resolution: Duplicate
-
P3
-
8, 11, 15, 16
-
Issue observed only Linux environment
-
x86_64
-
linux_ubuntu
ADDITIONAL SYSTEM INFORMATION :
Linux Mint 19.3 Cinnamon 4.4.8, Kernel 5.4.0-65-generic x86_64
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
Also tested (with the same issue) in:
Ubuntu 18.04.5 Gnome 3.28.4, Kernel 5.4.0-62-generic x86_64
java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Adding a really long line of characters to a JTextArea component causes the rendering to draw characters over each other. The actual line length when this occurs seems to be font size dependent. When tested using the standard Dialog font with a font size of 14 then the breaking point seems to be somewhere around 9000 characters. Tested in Linux, Windows 7/10 and MacOS and this problem only occurs in Linux.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the submitted test source in a Linux environment. If needed, increase line size or font size until the effect is visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text should render correctly in the JTextArea component.
ACTUAL -
The text seems to overlap in some or all parts of the line, depending on its length.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.stream.IntStream;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
public class JTextAreaBug {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new TestFrame().launch());
}
}
class TestFrame extends JFrame {
private JTextArea txt = new JTextArea(10, 80);
private JTextField len = new JTextField("9000", 6);
private JTextField size = new JTextField("14", 4);
private JComboBox<String> name;
TestFrame() {
setTitle("JTextArea - long line render bug example");
JButton btn = new JButton("Refresh");
btn.addActionListener(e -> refresh());
name = new JComboBox<String>(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
name.setSelectedItem(txt.getFont().getFamily());
JPanel ctrl = new JPanel();
initCtrl(ctrl, "Line length:", len);
initCtrl(ctrl, "Font name:", name);
initCtrl(ctrl, "Font size:", size);
ctrl.add(btn);
refresh();
getContentPane().add(BorderLayout.NORTH, ctrl);
getContentPane().add(BorderLayout.CENTER, new JScrollPane(txt));
}
void launch() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
}
private void refresh() {
try {
txt.setFont(new Font(name.getSelectedItem().toString(), Font.PLAIN, Integer.parseInt(size.getText())));
int n = Integer.parseInt(len.getText());
StringBuilder res = new StringBuilder(n);
IntStream.range(1, n).forEach(i -> res.append((char) (0x20 + i % 0x5E)));
txt.setText(res.append("\n").toString());
} catch (NumberFormatException e) {
txt.setText("Bad input. Adjust and retry.\nDetails: " + e);
}
invalidate();
repaint();
}
private final void initCtrl(Container parent, String label, JComponent c) {
parent.add(new JLabel(label));
parent.add(c);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found.
FREQUENCY : always
Linux Mint 19.3 Cinnamon 4.4.8, Kernel 5.4.0-65-generic x86_64
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
Also tested (with the same issue) in:
Ubuntu 18.04.5 Gnome 3.28.4, Kernel 5.4.0-62-generic x86_64
java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Adding a really long line of characters to a JTextArea component causes the rendering to draw characters over each other. The actual line length when this occurs seems to be font size dependent. When tested using the standard Dialog font with a font size of 14 then the breaking point seems to be somewhere around 9000 characters. Tested in Linux, Windows 7/10 and MacOS and this problem only occurs in Linux.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the submitted test source in a Linux environment. If needed, increase line size or font size until the effect is visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text should render correctly in the JTextArea component.
ACTUAL -
The text seems to overlap in some or all parts of the line, depending on its length.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.stream.IntStream;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
public class JTextAreaBug {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new TestFrame().launch());
}
}
class TestFrame extends JFrame {
private JTextArea txt = new JTextArea(10, 80);
private JTextField len = new JTextField("9000", 6);
private JTextField size = new JTextField("14", 4);
private JComboBox<String> name;
TestFrame() {
setTitle("JTextArea - long line render bug example");
JButton btn = new JButton("Refresh");
btn.addActionListener(e -> refresh());
name = new JComboBox<String>(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
name.setSelectedItem(txt.getFont().getFamily());
JPanel ctrl = new JPanel();
initCtrl(ctrl, "Line length:", len);
initCtrl(ctrl, "Font name:", name);
initCtrl(ctrl, "Font size:", size);
ctrl.add(btn);
refresh();
getContentPane().add(BorderLayout.NORTH, ctrl);
getContentPane().add(BorderLayout.CENTER, new JScrollPane(txt));
}
void launch() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
}
private void refresh() {
try {
txt.setFont(new Font(name.getSelectedItem().toString(), Font.PLAIN, Integer.parseInt(size.getText())));
int n = Integer.parseInt(len.getText());
StringBuilder res = new StringBuilder(n);
IntStream.range(1, n).forEach(i -> res.append((char) (0x20 + i % 0x5E)));
txt.setText(res.append("\n").toString());
} catch (NumberFormatException e) {
txt.setText("Bad input. Adjust and retry.\nDetails: " + e);
}
invalidate();
repaint();
}
private final void initCtrl(Container parent, String label, JComponent c) {
parent.add(new JLabel(label));
parent.add(c);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None found.
FREQUENCY : always
- duplicates
-
JDK-8026261 xrender: drawString wrapping, not clipping.
-
- Open
-