Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : I:\>java -version java version "1.5.0_11" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03) Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : I:\>ver Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : For several years, I have been displaying marked up DNA sequence in a JTextPane -- DNA is one long string without spaces or line breaks. Until jre 1.5.0_10 on windows, the JTextPane would wrap my text at the last character that would fit in the component -- logical and exactly what I want. but in version 1.5.0_10 line wrapping seems to chunk by AttributeSet (see working code example in "steps to reproduce" below). This makes no sense and it any case breaks existing applications like mine. Screen shot on how this has affected my production application here: http://everydaysystems.com/usenet/JTextPane/ STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile and run the code sample below and run on jre 1.5.0_4 on windows and then on jre1.5.0_10 or higher on windows (I'm not sure how versions in between fare, except that 1.5.0_7 on the mac works fine). You will see very different line wrapping in the JTextPane. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Here is a screenshot of how the line wrapping has changed in version 1.5.0_10 http://everydaysystems.com/usenet/JTextPane/ Line wrapping used to chunk by "character" for string with no internal spaces, now it seems to chunk by AttributeSet. I want the old version back! ACTUAL - I saw line breaks inserted at AttributeSet boundaries. This makes no sense and is a radical and undocumented change from previous versions of the JRE. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; public class JTextPaneWrapChangeDemo { public JTextPaneWrapChangeDemo() { super(); } public static void main(String[] args) { JTextPaneWrapChangeDemo demo = new JTextPaneWrapChangeDemo(); demo.run(); } public void run() { JFrame frame = new JFrame(); frame.setSize(400, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane textPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(textPane); frame.add(scrollPane); textPane.setEditable(false); textPane.setFont(new Font("Courier", Font.PLAIN, 12)); MutableAttributeSet exonAttributeSet = new SimpleAttributeSet(); MutableAttributeSet intronAttributeSet = new SimpleAttributeSet(); StyleConstants.setFontSize(exonAttributeSet, 12); StyleConstants.setForeground(exonAttributeSet, Color.blue); StyleConstants.setFontSize(intronAttributeSet, 12); StyleConstants.setForeground(intronAttributeSet, Color.black); try { Document d = textPane.getDocument(); d.insertString(d.getLength(), exon1, exonAttributeSet); d.insertString(d.getLength(), intron1, intronAttributeSet); d.insertString(d.getLength(), exon2, exonAttributeSet); d.insertString(d.getLength(), intron2, intronAttributeSet); d.insertString(d.getLength(), exon3, exonAttributeSet); } catch (BadLocationException e) { System.out.println("bad location exception" + e); } frame.show(); } String exon1 = "ATGCCACCAAAAGCGCGTATAAACTCAAAAAATTCAGTTGAGCAGGAGGGAAGGGTCCTACTTGCAGTATCAGCTTTGAAAAATAAGGAAATTCTCAATATTCGTGAAGCTGCGCGTGTCTATAATGTGCCTTATACTACCCTCCAGCGGCGCCTAAAGGGGCATACTTTTCGAGCTGAATTACGCGCAAATGGCCATAAAATGACTCAGAATGAAGAGGATTCACTTATTAGATGGATTCTATCTATGGATCAACGTGGAGCGGCTCCCCGACCGTCCCATGTACGAGAAATGGCGAATATCCTGCTTGCGCAGCGTGGTTCAACTCCTACCCAGACTGTTGGAGAGAAATGGGTATATAACTTCATTAATCGGCATGATGAGATCAAAACCCGATTCTCTAGGCGCTATAACCACCAGCGTGCTAAATGTGAAGACCCAAAGATTATCCTGGAATGGTTCAATCGTGTCCAGATCACAATAATGCAGCATGGGATTACACTGGAAGATATCTACAACTTTGATGAAACTGGCTTTGCAATGGGCTTAGTAGCTACTGCTAAG"; String intron1 = "GTAGTTACAAGAGCTGAGATGCTTAGTCGGCCCTTCCTTATCCAGCCAGGGAACCGCGAATGGGTTACCTCTATAGAGTGTATTAACTCTACTGGCTGGGTGCTTCCACCATGCATTATCTTCAAGGGAAAGGTCCATATTGAGGACTGGTATTAAGATACAGCCTTACCAGCAGACTGGCGGATCGAGGTCAGTGAGAATGGATGGACGACTGATCAGATTGGATTACGATGGCTTCAAAAAGTCTTTATTCCTGCTACTACCAGTCGTACAACTGGTAGATATCGACTATTAATTCTTGATGGCCATGGGAGCCATCTAACACCACAGTTTGATCAAATCTGCACTGAGAATGATATCATTCCAATCTGCATGCCTGCACATTCATCACATCTCCTCCAGCCTCTAGATGTTGGCTGTTTCTCTCCTCTTAAGCGTGCGTATGGCCGCTTGATTGAGGATAAGATGCGGCTTGGTTTCAACCATATTGACAAGTTTGATTTCCTTGAGGCCTATCCACAAGCTCATACGGCAATCTTTTCAGCAGATAATATTAAAAGTGGCTTTTCAGCAACTGGATTAATACCACTGAATCCAGATCGGGTGCTCAGTCAGCTTAATATCCAGCTTAGAACACCTACACCACCAGGCAGCCGATCAACTAATTCTGTCCCAAAAACACCTTACAATCTCAAGCA"; String exon2 = "GCTGAAGAAGCAGGAAACTACGCTTAAGAAGCTACTTAGGGAGCGTACATACAGCCCTCCTACCCCTACAAAGGCTGTGCTAGGTCAGATTATCAAGGGGTGTGAGATGGCAATGAATAACGCTGCCCTTCTTGCAAAGGAAAATCATGATCTACGTGCTGCACATGAAAAGCACCTTCAAAAGCAGAAGCGATCTAGGCGGCAGATAGAAACTGCA"; String intron2 = "GTGGGATTATCTATCCAGGAAGGGCAGGAGATCATTTAACGCAGGGATCAGGCTGCTGAAGCTATCCCAACTATCCCTCCAGAGCAGGTAGTAGATACAGAACAACGCCCTCAACGGGCACCCCCACGCTGCAGTGACTGCCATATTCTAGGCCATAGGCGATTGCAATGTCCGCAGCGCAAGAATAACTAGATTTAGTAATAAAATCATGTTTTAGGGGTTCAAAATAGCCTCCAATTTCGGCCGCGGCCAAATTCTATAG"; String exon3 = "TATGGTGATCCGCTCGGTTACGTGATCCGCTCGCTTACCGATTACGTTACTTCTCTGGAAGACGATCCTGGACTAAGTCATTTCCTTTTGCGTAGTTCAGCGGATTTTTTTTTTCTTCTGCTACTTGGGGTCGCTGAAGATGGAATCAATCAGACGT"; } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Tell users to use an older JRE. This is not satisfactory. Release Regression From : 5.0u7 The above release value was the last known release where this bug was not reproducible. Since then there has been a regression.
|