Results 1 to 3 of 3

Thread: setting font of selected text in a JTextPane

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    setting font of selected text in a JTextPane

    I just can't seem to figure this crap out. I already had to convert all my code into a JTextPane just so I could change the style of text, and now I can't get it to work.

    Here is the junk I have so far:

    Code:
     public void processBoldText()
     {
    	 MutableAttributeSet keyWord = new SimpleAttributeSet();
    		StyleConstants.setBold(keyWord, false);
    	 int left = textArea2.getSelectionStart();
    	 int right = textArea2.getSelectionEnd();
    	 int length = right - left;
    	 doc.setCharacterAttributes(left,length,keyWord, true);
    
     }

  2. #2

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: setting font of selected text in a JTextPane

    Just so you don't get confused, textArea2 is my JTextPane...lol

    Also doc is the document I created from the textpane

  3. #3

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: setting font of selected text in a JTextPane

    Never mind. I figured it out.

Posting Permissions

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



Click Here to Expand Forum to Full Width