Re: JTextPane line wrap change in windows JRE 1.5.0_10?



Below is a simple code sample illustrating the problem.

When I run this code on my mac with jre 1.5.0_7 and on my pc with jre
1.5.0_4 lines are wrapped chunked by character. This is exactly what I
want and it makes sense.

But when I run this code on my pc with jre 1.5.0_10 lines are wrapped
chunked by AttributeSet "style." I can't see how this is not a bug...
but perhaps I'm missing something.


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";

}

.



Relevant Pages

  • Re: JTextPane line wrap change in windows JRE 1.5.0_10?
    ... Sun officially acknowledged that this is a bug. ... d.insertString, exon1, exonAttributeSet); ... intronAttributeSet); ... String intron1 = ...
    (comp.lang.java.gui)
  • Re: [opensuse] Editting PATH variable
    ... Recently I updated to jre v1.6.0, and the new PATH string should be ... But then I decided that what I really need is a JDK, ... Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org ...
    (SuSE)
  • Re: [opensuse] Editting PATH variable
    ... Recently I updated to jre v1.6.0, and the new PATH string should be ... The first thing is that Java is a bit special about it handles these ... The jre that I installed was indeed installed through YaST from an rpm package: ...
    (SuSE)
  • Re: [opensuse] Editting PATH variable
    ... Recently I updated to jre v1.6.0, and the new PATH string should be ... The first thing is that Java is a bit special about it handles these ... The jre that I installed was indeed installed through YaST from an rpm package: ...
    (SuSE)
  • [opensuse] Editting PATH variable
    ... Recently I updated to jre v1.6.0, and the new PATH string should be ... But then I decided that what I really need is a JDK, ... The sources I have found from a Google search indicate that I should change the ...
    (SuSE)