Highliting more than one word using JTextArea

I want to highlight more than one word using JTextArea. For example.
My car color is red.
My friend's car color is black.
I want to highlight "red" in first sentence and friend in second sentence using JTextArea (both the sentences are in JTextArea). Can any one help me how to write program for this please.
Thanks in advance
regards
V.Umashanker

Highlighter h = textArea.getHighlighter();
Highlighter.HighlightPainter p =
    new DefaultHighlighter.DefaultHighlightPainter(color);
Object h1 = h.addHighlight(start1, end1, p);
Object h2 = h.addHighlight(start2, end2, p);...and to remove them:h.removeHighlight(h1);
h.removeHighlight(h2);This is assuming that you want both words highlighted in the same color (but a different color than the selection). If you want different colors, you'll have to create a separate painter for each color.

Similar Messages

  • How do I enable Firefox 4 to do a search on more than one word (e.g. "yahoo mail") without receiving the error message "the URL is not valid and cannot be loaded"?

    After loading Firefox 4.0, I changed the address bar search engine to Google Search by Name, so I'd be taken straight to the most relevant webpage when I type in a word.
    It works fine when I type in one word, but if I use a search with more than one word (e.g. "yahoo mail" or "google maps") I get an alert saying "The URL is not valid and cannot be loaded". Is there any way I can fix the address bar to accept multiple word searches?
    I've tried disabling all my add-ons, but it didn't make any difference.

    Hi, this should sort out your problem:
    1. Type in "about:config" into the address bar, this will open the settings menu. Click on "I'll be careful, I promise!"
    2. Search for "keyword.URL" in the filter bar.
    3. Enter "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=" into the value field.
    I'm no expert, but I had the same problem which got on my nerves after being so used to being able to type anything in, and following these steps fixed it.

  • Search Query Help – more than one word

    I have been struggling with this for weeks.  I used Dreamweaver to set up a lot of this and I think it is hindering me as I make changes to the code.
    I have a search interface that takes the input from a user (in the form of text) – searches though the db to match words – then return the results based on how many times the input is located in the db.
    I have this working very good for a single word input.  If you search for one word only – it works great.  But, if you try to input two words together – it returns no results.
    I have tried several different things to get this to work – like exploding the input then searching the db for each word in order.  The problems I get, I think, is that this conflicts with the code Dreamweaver wrote – I think where the code requests the value string.  But, each time I think I find a fix for one error – it creates several others – not just in the php code above the header – but in the php code in the body when I try to retrieve the results.
    It seems that I am just going around in circles.  But, there has to be simple way to search for more than one word in the db – count the matches – add the matches from each search together – then return the results ordered by the largest number of matches.
    I have even tried using a foreach statement – but received errors that I have never seen before.  Then after researching and trying to fix those errors – just received more and more errors.
    Please help.  If it cannot be done given the code I have – then please point me in the right direction to rewrite the code.
    Code is attached.

    Based on what you explained as your requirements, it is very easy. I'll just speak in psuedo-code.  You will need to parse the input into seperate words. If there can be an unknown number of words you can store those in a string array.
    Then just use the array to build your where clause using the IN predicate or using the = and OR operators.
    Select count(*), keyword
    where keyword in (term[0], term[1], etc)
    group by keyword
    order by count(*) desc
    If this is not what you meant, then you will need to explain your requirements in more detail. As you have discovered, once your requirements exceep the capabilities of DW's behaviors, you will need to become very familar with sql and your server side scripting language. If you don't understand what the DW code is doing (as evidenced by your comments in the attachment), then you really are not ready to start modifying it.

  • GetParameter() with more than one word

    hi all
    i have these statement in my Servlet
    String cust = rs.getString(1);
    out.println("<INPUT TYPE=radio NAME=cdnames VALUE="+ cust + ">"+ cust + "<br>");
    out.println("<input type=submit>");
    out.println("</form>");
    String lastName = request.getParameter("cdnames");
    out.println("<P>"+lastName+"</P>");
    so as u can tell there are some radio buttons on the page and i want to see which one user selected. It works fine. But when i have a radio button with more than one word..it just returns the first word. For example if my radio button is "Sudesh Sharma" then the value in my String lastName will just be Sudesh and not Sudesh Sharma. How can i fix this?

    It is always a good idea to surround all html attribute values in quotes. And why you are at it, always use lower case for html tags:
      String cust = rs.getString(1);
      out.println("<input type=\"radio\" name=\"cdnames\" value=\""+ cust + "\"/>"+ cust + "<br/>");
      out.println("<input type=\"submit\">");
      out.println("</form>");
      String lastName = request.getParameter("cdnames");
      out.println("<p>"+lastName+"</p>");

  • How to backup more than one database using powershell

    I am Trying to backup more than one database using the following script but no luck. I want user to type on command line the database they want to backup, e.g all databases that have "test" at the front like test.inventory, test.sales so i want
    user to type test.* and it backs up all databases related to test. Here is the script
        #$date = Get-Date -Format yyyyMMddHHmmss
        #$dbname = 'test.inventory'
        $dbToBackup = "test.inventory"
        cls
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | 
        Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") 
        | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-
        Null
        Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral,   
        PublicKeyToken=89845dcd8080cc91"
        $server = New-Object Microsoft.SqlServer.Management.Smo.Server($env:ComputerName) 
        $server.Properties["BackupDirectory"].Value = "C:\_DBbackups"
        $server.Alter()
        $backupDirectory = $server.Settings.BackupDirectory
        #display default backup directory
        "Default Backup Directory: " + $backupDirectory
        $db = $server.Databases[$dbToBackup]
        $dbName = $db.Name
        $timestamp = Get-Date -format yyyyMMddHHmmss
        $smoBackup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup")
        #BackupActionType specifies the type of backup.
        #Options are Database, Files, Log
        #This belongs in Microsoft.SqlServer.SmoExtended assembly
        $smoBackup.Action = "Database"
        $smoBackup.BackupSetDescription = "Full Backup of " + $dbName
        $smoBackup.BackupSetName = $dbName + " Backup"
        $smoBackup.Database = $dbName
        $smoBackup.MediaDescription = "Disk"
        $smoBackup.Devices.AddDevice($backupDirectory + "\" + $dbName + "_" + $timestamp +   
        ".bak", "File")
        $smoBackup.SqlBackup($server)
        #let's confirm, let's list list all backup files
        $directory = Get-ChildItem $backupDirectory
        $backupFilesList = $directory | where {$_.extension -eq ".bak"}
        $backupFilesList | Format-Table Name, LastWriteTime

    Or i am using this script which backs up everything except tempdb but dont know how to modify this so that it backs up up all test related databases
    Is there a way that i use test.*
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
    $s = new-object ("Microsoft.SqlServer.Management.Smo.Server") $instance
    $bkdir = "C:\_DBbackups" #We define the folder path as a variable 
    $dbs = $s.Databases
    foreach ($db in $dbs) 
         if($db.Name -ne "tempdb") #We don't want to backup the tempdb database 
         $dbname = $db.Name
         $dt = get-date -format yyyyMMddHHmm #We use this to create a file name based on the timestamp
         $dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup")
         $dbBackup.Action = "Database"
         $dbBackup.Database = $dbname
         $dbBackup.Devices.AddDevice($bkdir + "\" + $dbname + "_db_" + $dt + ".bak", "File")
         $dbBackup.SqlBackup($s)

  • More than one user "using an expression" in a BPM Task

    Hello,
    I want to send a notification step for multiple users. I see two options
    1. Choose one or more UME principals.
    2. Use an expression.
    However I have to send the notification for more than one user using an expression. I'm using this expression, 
    getPrincipal(DO_xyz)
    but this only works for one user. I need something like this
    getPrincipal(DO_xyz);  getPrincipal(DO_xyz2);  getPrincipal(DO_xyz3)
    But this is not possible. I can't use a group because all this information is dynamic and it's born within the process.
    Please, How can I solve this?
    Best Regards
    SU

    Hello Abhijeet,
    I've seen that I can use the getPrincipals adding in the XSD an string with 1..* cardinality. However I don't know how to map an attribute from the UITask to that new attribute in the XSD because in Web Dynpro I can't create an string with cardinality 1..*
    I've tried to create a node (1..*) with a String inside in the UI but I couldn't map it to the process context, it shows me an error that I cannot map a node to a String.
    Thanks
    Regards
    SU

  • Is it possible to install Lightroom 4.1 on more than one computer using the same product code?

    is it possible to install Lightroom 4.1 on more than one computer using the same product code?

    Yes, your license key is cross platform PC & or Mac you are allowed to have two current installations with one in use at any point in time. You can uninstall / install as many times as is necessary so long as you adhere to the limits.

  • How to pull groups from more than one OU using weblogic "All Groups Filter" from AD.

    Hi,
    Please help me for pulling groups from more than one OU using weblogic "All Groups Filter" from AD.
    AD structure is:
    c001639domain.local
           ||
           ||
        OU=Security_Groups
                      ||
                      ||
                      >> OU=CORP_ECM---> n number of group
                      >> OU=CORP_hodata--> n number of group
                      >> OU=CORP_citrix--> n number of group
                      >> OU=CORP_driver --> n number of group
                      >> OU=CORP_temp --> n number of group
    Requirement is i want to filter groups from OU=CORP_ECM and OU=CORP_hodata.
    Thanks,
    Jagan.

    I used below option but its not working getting zero groups.
    (&(objectClass=group)(|(ou=CORP_ECM,dc=Domain,dc=com)(ou=CORP_hodata,dc=c001639domain,dc=local)))

  • Can i backup more than one iphone using itunes on pc

    can i backup more than one iphone using itunes on pc

    Yes. It ought not to matter, but make sure you give each device a unique name.
    tt2

  • How do u save datas more than one table using net beans ide using JSF

    Hi,
    I am new to JSF.
    I save / delete / update / New master table using POJO (Plain Old Java Objects), database - oracle and Toplink Persistence Unit.
    How do u save data more than one table using net beans ide using JSF (I am using POJO) ?
    and also Tell me the reference book for JSF.
    Thanks in advance.
    regards,
    N.P.Siva

    SivaNellai wrote:
    I am new to JSF.
    So, I am using net beans IDE 6.1 from sun microsystem. It is a free software.No, you don't drag'n'drop if you're new to JSF. Switch to source code mode. Write code manually, with the help of IDE for the speed up.
    So, please guide me the reference books, articles. I need the basic understanding of JSF, net beans IDE.[JSF: The Complete Reference|http://www.amazon.com/JavaServer-Faces-Complete-Reference/dp/0072262400] is a good book. The [JSF specification document|http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html] is also a good reading to understand what JSF is and how it works. There are also javadocs and tlddocs of Sun JSF Mojarra.

  • Trimming more than one Words

    I have a Name field in my DB which can have more than one
    name seperated by spaces. I want to trim this name-field to just
    one word while outputting.
    Example:
    "Michael Theodor John"
    Is outputted as simply
    "Michael"
    I'm working with trimming and find but not quite getting it
    right. Anyone suggestions?
    Thank you very much,
    Henrik

    Just to spread the knowledge of CF functions you could have
    also used
    the listFirst function which returns the first element of a
    list.
    <cfoutput>#listFirst([youqueryname].name,"
    ")#</cfoutput>

  • How can i choose more than one transition using idvd. please help..

    Hi my name is Luis and I took pictures and wanted to make a slideshow but when i want to choose more than one transition it wont let me. It will only let me choose just one. I would like it so the photo transition was random not just one. Please Help me if someone knows.. Thank You Very Much

    Syncing and backing up in iTunes can be accomplished with multiple devices. They identify the devices based on the phone number, phone name, etc. The only way you would have an issue is if you were using different calendar contacts on the computer. http://support.apple.com/kb/ht1495

  • Can more than one ipod use an itunes library

    Sorry for the newbe qestion but I need some advice for my daughters ipod. I have two libraries on two different computers. how do i set the itunes to manual sync. Can I also sync different ipods, we have several.
    thx

    *I have two libraries on two different computers. how do i set the itunes to manual sync*
    You don't set iTunes to manual, you set the iPod. If you want to connect and use an iPod on more than one computer or with more than one library you need to change the update preference in the iPod Summary tab to "Manually manage music and videos" and click Apply. The content of iTunes and the iPod are not syncronised in this mode so the two can be different. You can directly access the content of the iPod and play it through iTunes and you can drag and drop whatever you want to the iPod from either library:
    Using iPod with Multiple computers
    Managing content manually on iPod
    Syncing Music to iPod
    Something else to be aware of when using an iPod in manual mode is that the "Do Not Disconnect" message will remain on the display until you physically eject the device: Safely Disconnect IPod
    *Can I also sync different ipods, we have several*
    There are a few different ways to use multiple iPods with one computer. However if the iPods are also being used with multiple computers then you'll be using the manual method regardless and not any form of auto-sync. Have a look at this help page for all the suggestions: How to use multiple iPods with one computer

  • Can more than one laptop use a wireless network at a time?

    Hi...quick question and this may be a stupid one .. but a few months ago my uncle was living with us and had a laptop which had a wireless Internet connection. I had already had my Ibook set up and was using a wireless Internet connection. When he turned on his mine stopped working? Why was that happening? Also ... my dad is buying my mom a laptop for Xmas and I'm sure that it will have a wireless connection as well? I'm hoping that same thing will not happen again. Why would the wireless router only read one laptop in the same house? Aren't wireless routers suppose to read more than one computer? I just don't want my MAC to be unable to use the Internet once another laptop is in our house. Does anyone have any suggestions? Thanks a ton!
    IBook   Mac OS X (10.4.8)  
    IBook   Mac OS X (10.4.8)  

    Karen, welcome to the discussions.
    Using a wireless router will enable you to connect upwards of 50 computers all at the same time and simultaniously.
    Take care to read the set up procedure for the particular Wireless Router you are using for your Network.
    There are several different ways to confiqure a wireless Network.
    AS long as all of the computers you have, do in fact have wireless cards in them you shouldn't have a problem.
    There is a difference in the set up for PC and a Mac.
    There is also a difference in Wireless Routers and there capabilitys, some are for older wireless 802.11b compliant systems. Whereas the newer Routers or Base stations are for both older 802.11b and the newer 802.11g connections.
    They will say 802.11b/g or something close.
    Most will require you connect your Internet Service Providers Modem to the WAN Port of your choice of Wireless Router. Like I said follow the directions.
    Good Luck
    Don

  • How to attach more than one word document to an email?

    Hi there. 
    I've recently acquired an Ipad which I want to use while I'm out and about.  I generally respond to emails with attachments.  How do i go about doing this on the Ipad?  I've got a gmail address and making use of the gmail app to send and receive emails. 
    I would also like to be able to attach more than one attachment from the app pages.   Is there an app available which will allow me to do this?

    You can't do that from Pages or from the built in mail app. Look at this. I think it allows multiple attachments.
    http://www.redbits.com/iphone/groupemail/en/index.html

Maybe you are looking for

  • I need a Flash expert to help me urgently!

    This is a long shot and forgive me if I'm posting in the wrong forum- I am a web designer and I have a client who has asked me to do a project for him very quickly in Flash. He's given me a template and, whilst Flash isn't my strong point, I've been

  • How do I undo locking myself out of Lightroom 4?

    I was trying to figure out how to export pictures to a flashdrive and not disturb Lightroom 4.  Now I'm locked out.  Computer shows:  Lightroom 4 Catalog.Ircat-journal  and Lightroom 4 Catalog,Ircat.lock.  Lightroom 4 shows files as offline or missin

  • Down Payment reversal

    My Business process- I receives the down payment from the customer, we post that payment through F-29, now some how customer want to take back that advance. How can i able to cancell or reverse the down payment which i took from the customer. Waiting

  • Trade-in Value of iBook G4 (White)

    Hi, I would like to know what's the trade-in value for my iBook G4 (color: White) Mac OS X Version 10.4.10? And does anyone know a good second hand buyer for my iBook? I am thinking of buying a new MacBook soon. Thank you!

  • The web ticket is invalid

    Hi guys, I'm following the steps from https://ucwa.lync.com/documentation/KeyTasks-CreateApplication all work fine until the step #9 I get an valid AccesToken  and include in the header and I'm doing the post to https://myshost/ucwa/oauth/v0/applicat