Moving the JScrollPane horizontally results in blurry text

I have a TextArea inside a JScrollPane inside a standard JPanel.

JPanel panelMain = new JPanel(); panelMain.setBorder(titledBorder1); panelMain.setBounds(new Rectangle(2, 5, 970, 700)); panelMain.setLayout(null); JTextArea fieldBody = new JTextArea(); JScrollPane fieldBodyScrollPane = new JScrollPane(fieldBody); fieldBodyScrollPane.setBounds(70, 140, 790, 500); panelMain.add(fieldBodyScrollPane); 

When I print enough text on one line, a horizontal pen appears - for now, good. But when I start moving the pen left and right, the text becomes blurry (see. Image). Interestingly, nothing strange happens when I move the text area up and down.

blured text in jscrollpane when scrolling horizontally

I am using Ubuntu 12.04 with Unity. This graphic artifact never seemed to me. Any hints what might be the problem?

+4
source share
3 answers
 import java.awt.GridLayout; import javax.swing.*; import javax.swing.border.*; public class CaseForLayoutsNumber547 { CaseForLayoutsNumber547() { Border titledBorder1 = new TitledBorder("Case for Layouts #547"); // START: code snippet variant JPanel panelMain = new JPanel(new GridLayout()); panelMain.setBorder(titledBorder1); JTextArea fieldBody = new JTextArea(5,40); JScrollPane fieldBodyScrollPane = new JScrollPane(fieldBody); panelMain.add(fieldBodyScrollPane); // END: code snippet variant JOptionPane.showMessageDialog(null, panelMain); } public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { new CaseForLayoutsNumber547(); } }; SwingUtilities.invokeLater(r); } } 

I do not see any scroll artifacts in this SSCCE. You?

+4
source

Here is @Andrew SSCCE displaying itself; It looks the same with Ambience or Radiance.

image

  $ lsb_release -a
 No LSB modules are available.
 Distributor ID: Ubuntu
 Description: Ubuntu 12.04.1 LTS
 Release: 12.04
 Codename: precise
 $ java -version
 java version "1.6.0_24"
 OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1)
 OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

Addition. If you look at your screenshot without receiving the praise of opacity , this can lead to a rendering artifact, and the default settings may differ Look and Feel.

+2
source

This problem occurs in OpenJDK (at least 6 and 7, and at least on Linux) and does not occur on Oracle Java 6 and 7 (on Linux).

The workaround suggested by mKorbel works for me:

 scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); 

So, I think this is a bug in OpenJDK.

+1
source

Source: https://habr.com/ru/post/969900/


All Articles