-
Bug
-
Resolution: Fixed
-
P3
-
9, 11, 12
-
b127
-
b15
-
x86_64
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8288782 | 11.0.17 | Sergey Bylokhov | P3 | Resolved | Fixed | b01 |
JDK-8284465 | 11.0.15.0.1-oracle | Suman Rajkumaar Kodandarama | P3 | Closed | Fixed | b01 |
ADDITIONAL SYSTEM INFORMATION :
Windows 10
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Line wrapping of JTextArea doen't work correctly if you set wrapStyleWord = true and you use a UI scale (either by setting "sun.java2d.uiScale" or by setting display scale of Windows). In the example below the last long word ("hhhh...") is not wrapped although there is not enough line space. If you use wrapStyleWord = false or no UI scale than it works.
REGRESSION : Last worked in version 8u181
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute example below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Last word "hhhh...." is wrapped to the next line.
ACTUAL -
A part of the last word is hidden.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URISyntaxException;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
public class JTextAreaTest {
public static void main( String[] args ) throws IOException, URISyntaxException {
System.setProperty( "sun.java2d.uiScale", "1.25" );
JFrame frame = new JFrame();
frame.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing( WindowEvent e ) {
System.exit( 0 );
}
} );
frame.setSize( 720, 300 );
frame.setLayout( new BorderLayout() );
JTextArea textArea = new JTextArea();
textArea.setLineWrap( true );
textArea.setWrapStyleWord( true );
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 100; i++) {
sb.append( "zz zzz zzzz zz zz zz zzz xzzzz zzzzzzzzzzzzzzzzx yyyyyyy tttttttttt sssss hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n" );
}
textArea.setText( sb.toString() );
JScrollPane pane = new JScrollPane( textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
frame.add( pane, BorderLayout.CENTER );
frame.setVisible( true );
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Line wrapping of JTextArea doen't work correctly if you set wrapStyleWord = true and you use a UI scale (either by setting "sun.java2d.uiScale" or by setting display scale of Windows). In the example below the last long word ("hhhh...") is not wrapped although there is not enough line space. If you use wrapStyleWord = false or no UI scale than it works.
REGRESSION : Last worked in version 8u181
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute example below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Last word "hhhh...." is wrapped to the next line.
ACTUAL -
A part of the last word is hidden.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URISyntaxException;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
public class JTextAreaTest {
public static void main( String[] args ) throws IOException, URISyntaxException {
System.setProperty( "sun.java2d.uiScale", "1.25" );
JFrame frame = new JFrame();
frame.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing( WindowEvent e ) {
System.exit( 0 );
}
} );
frame.setSize( 720, 300 );
frame.setLayout( new BorderLayout() );
JTextArea textArea = new JTextArea();
textArea.setLineWrap( true );
textArea.setWrapStyleWord( true );
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 100; i++) {
sb.append( "zz zzz zzzz zz zz zz zzz xzzzz zzzzzzzzzzzzzzzzx yyyyyyy tttttttttt sssss hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n" );
}
textArea.setText( sb.toString() );
JScrollPane pane = new JScrollPane( textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
frame.add( pane, BorderLayout.CENTER );
frame.setVisible( true );
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8288782 JTextArea line wrapping incorrect when using UI scale
-
- Resolved
-
-
JDK-8284465 JTextArea line wrapping incorrect when using UI scale
-
- Closed
-
- relates to
-
JDK-8132119 Provide public API for text related methods in SwingUtilities2
-
- Resolved
-