Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Word wrapping incorrect inside JTextPane on MAC OS 10.5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Word wrapping incorrect inside JTextPane on MAC OS 10.5



Hello java-dev team,

 

In my application, I am using JTextPane as a text editor to create RTF text. The problem I observed with the JTextPane on MAC OS is: whenever I am changing any of the text property (font color, font name, font style like bold, italic or underline) and then enter the characters without providing space, the whole word gets wrapped to the next line from the point where exactly the property change starts i.e. the new formatted text is jumped to the next line from the starting point of formatting.

 

My requirement is, as I am not adding any space character while changing the property, the characters should be entered in the sequence and should come to new line as per normal word-wrap rule.

 

Can anybody help me out in this regards with some solution as itÂ’s a very urgent requirement?

 

Below I am also providing the sample code to check the behavior. There is no dynamic facility to change the property, I am providing the text with multiple formatting settings through code itself. To reproduce the above issue, just type the characters from the property change point, you will see the whole word jumping to new line.

 

import javax.swing.*;

import javax.swing.text.*;

 

public class TestWrapping {

    JScrollPane scroll;

    JEditorPane edit;

    public TestWrapping()  throws Exception {

        final JFrame frame=new JFrame();

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 

        edit=new JEditorPane();

        edit.setEditorKit(new StyledEditorKit());

        scroll=new JScrollPane(edit);

        edit.getDocument().insertString(0,"11111111111111222222222222222222222222222222222222222",null);

        MutableAttributeSet attrs=new SimpleAttributeSet();

        StyleConstants.setBold(attrs,true);

        ((StyledDocument)edit.getDocument()).setCharacterAttributes(30,5,attrs,false);

        StyleConstants.setUnderline(attrs,true);

        ((StyledDocument)edit.getDocument()).setCharacterAttributes(35,5,attrs,false);

        StyleConstants.setFontSize(attrs,25);

        ((StyledDocument)edit.getDocument()).setCharacterAttributes(40,5,attrs,false);

        frame.getContentPane().add(scroll);

        frame.setBounds(0,0,150,150);

        frame.show();

   }

 

    public static void main(String[] args) throws Exception {

        new TestWrapping();

    }

}

 

If you need any additional information, please let me know.

 

 

Thanks in advance.

 

Regards,

VPKVL

 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.