-
Bug
-
Resolution: Unresolved
-
P3
-
9, 11, 17, 21, 22
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows 10 and Windows 11 (and probably all previous Window)
A DESCRIPTION OF THE PROBLEM :
-Dsun.java2d.uiScale=x with x different than 1.0 doesn't scale correctly the tabulator in javax.swing.text.StyledDocument (Presented in JTextPane). Even with a x =1.01 ,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the source code below with
java -Dsun.java2d.uiScale=1.0 Example
java -Dsun.java2d.uiScale=1.01 Example
compare the results
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All columns should contain a value
ACTUAL -
The last column Col5 contains no entry for the line starting with "a" where the distinct "c" and "11" are erroneously concatenated in Col3 instead of being separated with a tabulator
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import javax.swing.text.StyleConstants;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.AttributeSet;
import javax.swing.text.StyleContext;
import javax.swing.text.StyleContext;
import javax.swing.text.TabSet;
import javax.swing.text.TabStop;
import javax.swing.*;
/** Buggy text presentation
java -Dsun.java2d.uiScale=1.01 Example
Expected result: All columns should contain an entry
Actual Result: The last column Col5 contains no entry for the line starting with "a".
*/
public class Example {
public static void main(String[] args) {
JTextPane tp = new JTextPane();
{
// setting tabs
int ncols = 5;
TabStop[] tabs = new TabStop[ncols]; //BUG: needs more
for(int i=0; i<tabs.length; i++)
{
//fails with right and decimal
// success with left and center and bar
int align = TabStop.ALIGN_DECIMAL;
tabs[i] = new TabStop(90*(i+1), align, TabStop.ALIGN_DECIMAL);
}
TabSet tabset = new TabSet(tabs);
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,
StyleConstants.TabSet, tabset);
tp.setParagraphAttributes(aset, false);
}
// writing some content
StringBuilder sb = new StringBuilder();
sb.append("Illustration of tab align_decimal bug with -Dsun.java2d.uiScale="+System.getProperty("sun.java2d.uiScale")+"\n");
sb.append("Quick bug observation #1: the last column should contain elements. c and 11 are in 2 separate columns.\n");
sb.append("observation #2: place the caret before the <a> and insert whitespaces.\n");
sb.append("\n\tCol 1\tCol 2\tCol 3\tCol 4\tCol 5");
sb.append("\n\ta\tb\tc\t11\t-1221");
sb.append("\n\t0\t1\t2\t3\t2.22");
sb.append("\n\td\te\tf\t1.23\t-3.33");
sb.append("\n\t0.0123\t-1.2341\t2.344\t3.1232\tend");
tp.setText( sb.toString() );
JFrame fr = new JFrame("Bug example");
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.getContentPane().add( new JScrollPane(tp), BorderLayout.CENTER);
fr.setSize(800,500);
fr.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use Align_CENTER or ALING_LEFT instead, but this is only a bugfix.
FREQUENCY : always
Windows 10 and Windows 11 (and probably all previous Window)
A DESCRIPTION OF THE PROBLEM :
-Dsun.java2d.uiScale=x with x different than 1.0 doesn't scale correctly the tabulator in javax.swing.text.StyledDocument (Presented in JTextPane). Even with a x =1.01 ,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the source code below with
java -Dsun.java2d.uiScale=1.0 Example
java -Dsun.java2d.uiScale=1.01 Example
compare the results
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All columns should contain a value
ACTUAL -
The last column Col5 contains no entry for the line starting with "a" where the distinct "c" and "11" are erroneously concatenated in Col3 instead of being separated with a tabulator
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import javax.swing.text.StyleConstants;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.AttributeSet;
import javax.swing.text.StyleContext;
import javax.swing.text.StyleContext;
import javax.swing.text.TabSet;
import javax.swing.text.TabStop;
import javax.swing.*;
/** Buggy text presentation
java -Dsun.java2d.uiScale=1.01 Example
Expected result: All columns should contain an entry
Actual Result: The last column Col5 contains no entry for the line starting with "a".
*/
public class Example {
public static void main(String[] args) {
JTextPane tp = new JTextPane();
{
// setting tabs
int ncols = 5;
TabStop[] tabs = new TabStop[ncols]; //BUG: needs more
for(int i=0; i<tabs.length; i++)
{
//fails with right and decimal
// success with left and center and bar
int align = TabStop.ALIGN_DECIMAL;
tabs[i] = new TabStop(90*(i+1), align, TabStop.ALIGN_DECIMAL);
}
TabSet tabset = new TabSet(tabs);
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,
StyleConstants.TabSet, tabset);
tp.setParagraphAttributes(aset, false);
}
// writing some content
StringBuilder sb = new StringBuilder();
sb.append("Illustration of tab align_decimal bug with -Dsun.java2d.uiScale="+System.getProperty("sun.java2d.uiScale")+"\n");
sb.append("Quick bug observation #1: the last column should contain elements. c and 11 are in 2 separate columns.\n");
sb.append("observation #2: place the caret before the <a> and insert whitespaces.\n");
sb.append("\n\tCol 1\tCol 2\tCol 3\tCol 4\tCol 5");
sb.append("\n\ta\tb\tc\t11\t-1221");
sb.append("\n\t0\t1\t2\t3\t2.22");
sb.append("\n\td\te\tf\t1.23\t-3.33");
sb.append("\n\t0.0123\t-1.2341\t2.344\t3.1232\tend");
tp.setText( sb.toString() );
JFrame fr = new JFrame("Bug example");
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.getContentPane().add( new JScrollPane(tp), BorderLayout.CENTER);
fr.setSize(800,500);
fr.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
use Align_CENTER or ALING_LEFT instead, but this is only a bugfix.
FREQUENCY : always