Results 1 to 4 of 4
  1. #1
    dorairaj is offline Member
    Join Date
    Jan 2009
    Location
    Hyderabad,India.
    Posts
    13
    Rep Power
    0

    Smile How to Get Text(RichText) from JTextPane

    hI aLL,

    I have a problem while getting text from the JtextPane. The text may consist of bold letter and italic and text may be in different font size and font name.
    I want get the exact data needs to store in databse. Now m able to change the text into bold, italic and font size and name by using caret Listener but the problem is getting exact text. pls suggest me
    Thx in advance.
    Last edited by dorairaj; 07-09-2009 at 01:57 PM.

  2. #2
    dorairaj is offline Member
    Join Date
    Jan 2009
    Location
    Hyderabad,India.
    Posts
    13
    Rep Power
    0

    Default

    Pls suggest me. Whre is Experts?

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    You can extract the style data and store it for future use in reconstruction of the styled text.
    For an example, see reply 2 in the thread Cut/copy/paste with style information intact for one technique of extracting style information from a JTextPane.

  4. #4
    dorairaj is offline Member
    Join Date
    Jan 2009
    Location
    Hyderabad,India.
    Posts
    13
    Rep Power
    0

    Default

    Thanks alot ,

    and tried the following code ,
    localStyleDoc = textpane.getStyledDocument();
    Element e = localStyleDoc.getCharacterElement(localLoop);
    localAttrSet = e.getAttributes();
    isBold = StyleConstants.isBold(localAttrSet);
    isItalic = StyleConstants.isItalic(localAttrSet);
    isUnderline = StyleConstants.isUnderline(localAttrSet);

    above code gives the each charater styles and i capture that style
    but i again m facing one problem with that code , i.e,
    suppose if enter exists(/r/n) in the text that charater attributes has given wrong styles
    how can i over come? pls suggest
    thanks in advance.
    Last edited by dorairaj; 07-15-2009 at 08:36 AM.

Similar Threads

  1. [SOLVED] jTextPane to xml
    By er_zhong in forum New To Java
    Replies: 9
    Last Post: 04-15-2009, 05:46 AM
  2. Insert text at abitrary point in a JTextPane
    By angues in forum AWT / Swing
    Replies: 6
    Last Post: 02-02-2009, 05:08 PM
  3. JTextPane with servlets
    By kinabaloo in forum Advanced Java
    Replies: 2
    Last Post: 07-11-2008, 07:32 AM
  4. JTextPane Styles Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 08:48 PM
  5. Transparent JTextPane
    By Ada in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2007, 10:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •