Not retaining the text highlight in jtextpane

I have a jtextpane and a button in a frame. when the user selects some text in textpane and clicks on the button, a word gets appended to the selected text and also gets highlighted. It works fine when the button is clicked but the when the focus changes, the highlighted text doesnt retain the color, but retains the appended text. is there anything i am missing in the code to retain the highlight?
private Highlighter.HighlightPainter yellowPainter = new DefaultHighlighter.DefaultHighlightPainter( Color.YELLOW);
public void actionPerformed(ActionEvent ae){
        JEditorPane textForComments = getEditor(ae);
                if (textForComments != null) {
                int caretPos1 = textForComments.getSelectionEnd();
                int selStart = textForComments.getSelectionStart();
               textForComments.getDocument().insertString(caretPos1, "ID", null);
               Object highlightTag = textForComments.getHighlighter().addHighlight(selStart ,caretPos1 , yellowPainter);
}

Selected text is only highlighted when focus is on the text component. Since you clicked on the button the button now has focus. You need to invoke
textForComments.requestFocusInWindow();

Similar Messages

  • How do i use the text highlighter on web pages

    I want to highlight some small print on a banking web page to email. The print is too small and will be missed if not highlighted. I have installed the text highlight add on in my tool bar but don't know how to use it.

    Hi Trease,
    Check to make sure that is it is not disabled in the about:addons page of your browser window.
    There are a few addons with that name, but I would also take a look at the description on its addons.mozilla.org page if you still have it.

  • Why does iPhoto (9.0/11) not retain the Event name when exporting more than one event? (using File - Export - Album name with number).

    Why does iPhoto (9.0/11) not retain the Event name when exporting more than one event? (using File -> Export -> Album name with number).
    Exporting a single Event retains the Event name which is what I'd expect. But highlighting more than one event and exporting it renames the images to Events 001.JPG, Event 002.JPG etc.
    I was recently on holidays and had all my events nicely split on Dad's computer but when I went to export it I couldn't retain any of this information. Now I have to replicate this all again on my computer.
    It wasn't possible to export the entire library as the external drive was fat32 format an I didn't want all of it. It would be nice to export a bunch of events to someone and have it retain the name.
    Does anyone have a work around or will this be fixed at some point by Apple?

    Why does iPhoto (9.0/11) not retain the Event name when exporting more than one event? (using File -> Export -> Album name with number).
    Exporting a single Event retains the Event name which is what I'd expect. But highlighting more than one event and exporting it renames the images to Events 001.JPG, Event 002.JPG etc.
    I was recently on holidays and had all my events nicely split on Dad's computer but when I went to export it I couldn't retain any of this information. Now I have to replicate this all again on my computer.
    It wasn't possible to export the entire library as the external drive was fat32 format an I didn't want all of it. It would be nice to export a bunch of events to someone and have it retain the name.
    Does anyone have a work around or will this be fixed at some point by Apple?

  • In Pages (5.2), in a table, superscript is not only not printing, but not printing the text around it. Bizarre

    In Pages (5.2), in a table, superscript is not only not printing, but not printing the text around it. Any answers?

    Known issue now for almost 9 months.
    Use Pages '09 if you have it.
    Peter

  • In Adobe Pro XI when converting an excel file to a pdf, the pdf is not retaining the page size settings.  Has anyone found a fix for this?

    In Adobe Pro XI when converting an excel file to a pdf, the pdf is not retaining the page size settings.  Has anyone found a fix for this?

    It shouldn't print each page as a separate job and
    each tab has a different name, so, even if it did, it
    ought to give the printouts the name of the tabs.
    It doesn't print each page as a separate job unless the orientation is different - that's the bug. And the name of the job is taken from the name of the window, not the name of the tabs. That's how every application works, which, I think, is why Excel allows the specific selection or the active sheets to be printed.
    Still, that does sound like a plausible explanation.
    However, even if presented with multiple prints with
    the same name, the spooler should print each one!
    The spooler does print each one - you can watch the spooler process the multiple jobs. I think, though, that they are being overwritten since all the jobs have the name of the window as the job title. And since this happens after the Save Dialog is presented, there's really nothing the application can do. To Excel, it's one job, the multiple orientations don't matter; it's just that Apple doesn't handle it correctly.
    As a workaround, you can print the selections one at a time and give them unique names and then rejoin them in one PDF file.

  • When converting tables in a MS Word 2010 or 2007 to PDF the table borders do not retain the correct thickness as identified in the word document.  Is there a solution for this issue?

    When converting tables in a MS Word 2010 or 2007 to PDF the table borders do not retain the correct thickness as identified in the word document.  Is there a solution for this issue?

    Please try with latest version of MS Word and Acrobat.
    Regards,
    Anoop

  • Why my firefox 7.0.1 in my ubuntu 11.10 is not show the text in every website it just show the pict and some chineese alphabet? and how to solve this problem?

    my firefox 7.0.1 in my ubuntu 11.10 is not show the text in every website it just show the pict and some chineese alphabet

    Upgrade your browser to Firefox 8 and check
    * getfirefox.com

  • Has anyone had issues with not hearing the text alerts on the iPhone 5?

    hello i have been having issues with my iphone 5 not hearing the text alert tones.it will go from time to time & only hear the vibrating sound, The wired part is all other alerts work fine , just text. 
    Has anyone having this same issue ? Also i noticed sometimes when i text, i'll see some crazy blury lines go across my screen like as i text it will move across any help?

    I have had that issue with no text alert sound and also with calls, no ring for the call but then I got a missed call or voicemail alert. Never had the blurry lines though. Right after I upgraded, the ring changed to a very short version of what I have selected and only rang once, other times not at all. This was a very big problem since I am working from my car most of the day and get a lot of calls and texts.  I did a reset with home button and button on the top as described in a post somewhere here on the forum and the problems stopped. So far so good. Give reset a try!

  • Is there a save option on iPhoto? Sometimes iPhoto does not retain the name on a face I've added to a photo.

    Sometimes iPhoto does not retain the name on a face I've added to a photo. I have 'added a face' then flipped to the next picture then back to that picture and the label has disappeared.

    No.  It's supposed to be automatic.  You might try repairing the library's database and then see if it still crops up now and then. If that doesn't help try rebuilding it the same way.
    Launch iPhoto with the Option+Command keys held down and select the database repair option in the rebild window:
    Then the rebuild option if necessary.
    OT

  • Does not copy the text

    Does not copy the text Please help me

    Can you explain what are you trying to copy and where?
    Can't you copy text from website to the clipboard or do you have a problem with pasting that text?
    * http://kb.mozillazine.org/Clipboard_not_working

  • Multiple select list not retaining the value for the first time

    Hi,
    I have a 3 select list depends on each other. select_list1 -- > select_list2 --> multiselect3. I have use denes example to create them.
    For the first time when I select values from 1,2,3 and runs a report based on it, it works fine but *does not retain the selected value in multiselect3.
    for the second time submit the process, it retails value in multiselect3. Please tell me if you came across this issue before
    Here is the code.
    function get_select_list_xml_VL(pThis,pSelect,pSelect1,pSelect2){
    var l_Return = null;
    var l_Select = html_GetElement(pSelect);
    var l_Select1 = html_GetElement(pSelect1);
    var l_Select2 = html_GetElement(pSelect2);
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=Cascading_Select_List_VL',0);
    get.add('F660_CASCADING_TEST',l_Select1.value + '_' + pThis.value + '_' + l_Select2.value);
    alert(l_Select1.value + '_' + pThis.value + '_' + l_Select2.value);
    // alert(document.getElementById("F660_CASCADING_TEST").value);
    gReturn = get.get('XML');
    if(gReturn && l_Select ){
    var l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var i=0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option");
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
    l_Opt_Xml.firstChild.nodeValue)
    get = null;
    function appendToSelect(pSelect, pValue, pContent) {
    var l_Opt = document.createElement("option");
    l_Opt.value = pValue;
    if(document.all){
    pSelect.options.add(l_Opt);
    l_Opt.innerText = pContent;
    }else{
    l_Opt.appendChild(document.createTextNode(pContent));
    pSelect.appendChild(l_Opt);

    Please ask any question if you dont understand about the problem.
    Thanks

  • N81 does not retain the correct date...

    My N81 got a very strange problem: it does not retain the correct date....
    Usually it's wrong by two days ago....!
    The S.O. Ver. is: 10.0.32 
    Thanks you and sorry for my english...! :-)

    hi there, have you checked that there is a firmware update for your model? v10 sounds like the original firmware for the N81. i would suggest checking on your PC via Nokia Software Updater for any firmware updates. the latest firmware version for the N81, unbranded or not, is v21.  
    If you found this or someone's comments helpful or like what that person has to say, please give some Kudos to their post!

  • I'm picking up all of the data script related to the sending / receipt of an e-mail along with the e-mail itself and can't find a way of not showing the text. Obviusly only a command but can't find it!

    I'm picking up all of the data script related to the sending / receipt of an e-mail along with the e-mail itself and can't find a way of not showing the text. Obviusly only a command but can't find it! Help!

    Shift-Command-H is the key-combo to switch 'Long Header'/'Standard Header' .
    Long way: Top Menu -> View -> E-Mail
    Stefan

  • My phone randomly doesn't ring when people call and not sound the text alert. I checked all the settings and them seem to be correct. Anyone know how to fix this?

    My phone randomly doesn't ring when people call and not sound the text alert. I checked all the settings and them seem to be correct. Sometimes it rings, many times it doesn't. I have missed several calls. Same with texts. Anyone know how to fix this?

    Symptoms
    No ringer sound
    Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 2)
    Go to Settings> General> Reset> Erase All Content and Settings. Warning: This will delete all user data on the device. Verify that you have a backup before proceeding. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 3)
    Restore device using latest version of iTunes. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Contact Apple for service options)

  • When I highlight my bank transactions and paste them on word, they do not retain the table format, why? answer in laymens terms please. I'm new to FF.

    I Have Windows XP and I use Microsoft Word to make a copy of my bank transactions. With IE the copy/paste always retains the table format. With FF it prints out as a continuing line.
    I had to open up IE to perform the action there.

    You can look at this extension:
    *Dafizilla Table2Clipboard: https://addons.mozilla.org/firefox/addon/1852

Maybe you are looking for

  • Upgrade issues - 11.1.0.6 to 11.1.0.7 on Windows Server 2003 R2 32bit

    Sooo...after upgrading from 11.1.0.6 to 11.1.0.7 I'm getting errors when trying to use EM and starting the database. Database Instance is down Host beehive Port 1521 SID hivedb Oracle Home C:\app\Administrator\product\11.1.0\db_1 Listener is UP Statu

  • Number Range (series) for Billing Document (F2) and Excise Invoice

    Hi All, I want to know how the number ranges / number series is defined for billing documents (F2) and excise invoice, for India business scenario. In India, the excise invoice is given to the customer so that he can the excise duty/ cenvat. This inv

  • Profit Center not getting uploaded through BAPI for MM01. Pls help

    Hello all,               I am getting an errror while uploading a file through BAPI for MM01 , The error says Error: Profit center 1000/sslcommon does not exist for material: AC2 *& Report  ZBAPI_DUMMY REPORT  ZBAPI_MM01. *& Report  ZBAPI2 TABLES FLA

  • Can't view .key package content

    Tonight I needed to view the package content of a saved Keynote 09 .key file. Right clicked on the file and the feature is no longer in the drop down menu. So I tried an 08 file using 09 and the feature is there. The work around was to save the file

  • Trying to type on a path (CS5) and get small circle with plus sign???

    I am trying for the first time to type on a path that I have made. I go to the type tool, type one letter which never appears...but the small circle with a plus sign inside it appears right at that spot on the path. Would love to know what is happeni