Results 1 to 5 of 5
  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default problem in JTextPane

    my problem in JTextPane

    i used it as oracle sql editor , i want to change the color of the word only in reserved words array such as (select,from ...etc)
    Last edited by jperson; 07-07-2010 at 02:27 PM.

  2. #2
    Join Date
    Feb 2009
    Posts
    15
    Rep Power
    0

    Default

    Try looking on this page, i think the highlighter is what you are looking for.

    JTextPane Highlight Example : TextPane**Swing JFC**Java

  3. #3
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default

    thank you thehighlander12 for your reply but this no i want

    i want to know how to color some words in text

    (example)-> when we use netbeans and write class it's color converted form black to blue ..

    i need please

  4. #4
    Join Date
    Feb 2009
    Posts
    15
    Rep Power
    0

    Default

    try doing that in an if statement that checks for the words. Don't forget to repaint.

    Font font = new Font("Serif", Font.ITALIC, 20);
    setJTextPaneFont(text, font, Color.blue);

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by thehighlander12 View Post
    try doing that in an if statement that checks for the words. Don't forget to repaint.
    Font font = new Font("Serif", Font.ITALIC, 20);
    setJTextPaneFont(text, font, Color.blue);
    What the is "setJTextPaneFont", as it's not part of any API I've seen? Would it be better to have the OP look into setting the styles of sections of his JTextPane's StyledDocument?

Similar Threads

  1. JTextPane focus problem
    By LeonLanford in forum AWT / Swing
    Replies: 1
    Last Post: 06-22-2010, 07:10 AM
  2. Replies: 1
    Last Post: 06-07-2010, 08:10 AM
  3. JTextpane
    By Mash in forum AWT / Swing
    Replies: 1
    Last Post: 04-15-2010, 07:36 PM
  4. Problem in adding new JTextPane at Runtime
    By png in forum AWT / Swing
    Replies: 12
    Last Post: 12-14-2009, 01:14 PM
  5. JTextPane with servlets
    By kinabaloo in forum Advanced Java
    Replies: 2
    Last Post: 07-11-2008, 07:32 AM

Posting Permissions

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