Results 1 to 3 of 3
  1. #1
    ravi.joshi53 is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Thumbs up What are the available tricks to hightlight any line in a text containing many lines?

    Hi, I have some piece of text contains 20-25lines. I want to draw all the text in a window and dynamically highlight any line of the text. For this reason, i am thinking to design a JPanel, which will put all the text in a textArea first but after that how to highlight the text? Can i change color of any line inside textArea? I guess it is there.
    Perhaps i have to use graphics class. but i don't know which one is advisable.
    Please suggest some better way in detail.
    Thank you.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: What are the available tricks to hightlight any line in a text containing many li

    Use the JTextComponent Highligher. Put text in a JTextArea. Get the highlighter and add a new HighlightPainter corresponding to the appropriate offsets
    See JTextComponent (Java Platform SE 6)
    Googling these terms should bring up a few examples that should get you started

  3. #3
    ravi.joshi53 is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Default Re: What are the available tricks to hightlight any line in a text containing many li

    Quote Originally Posted by doWhile View Post
    Use the JTextComponent Highligher. Put text in a JTextArea. Get the highlighter and add a new HighlightPainter corresponding to the appropriate offsets
    See JTextComponent (Java Platform SE 6)
    Googling these terms should bring up a few examples that should get you started
    Java Code:
    do{
    System.out.println("Thank you very much");
    }
    While(true)

Similar Threads

  1. Replies: 7
    Last Post: 03-05-2011, 10:25 AM
  2. Stepping through a text file line by line
    By evanlivingston in forum New To Java
    Replies: 10
    Last Post: 01-29-2011, 05:30 AM
  3. Replies: 8
    Last Post: 12-28-2010, 03:24 PM
  4. How to remove 2 last lines in a text file?
    By Marius in forum New To Java
    Replies: 2
    Last Post: 11-30-2008, 04:54 PM
  5. Remove duplicate lines from a text file
    By Dirt.Diver in forum New To Java
    Replies: 15
    Last Post: 06-25-2008, 03:08 PM

Tags for this Thread

Posting Permissions

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