How do I remove the last Char from a DefaultStyledDocument

Hello
This one sounds easy, I have a DefaultStyledDocument (displayed in a JTextPane) and i want to delete only the last character from it.
naturally i would try something like this:
myDoc.remove(myDoc.getLength()-1,1);but this only removes the second last character.
When i try
myDoc.remove(myDoc.getLength(),1);or even
myDoc.remove(myDoc.getLength()-1,2);I get a BadLocationException
What could I be doing wrong? this should be easy
Thanks in advance

What could I be doing wrong? this should be easy
Not could but did you do wrong
1) You didn't read the forum topic and as a result posted in the wrong forum. - shame on you.
2) indexes in Java are (almost) always zero based, so using the length as an index will fail. (if length is 2, the valid indexes are 0 and 1)
Thanks in advance

Similar Messages

  • Recently, U2 music appeared on my ipod without my requesting it or wanting it. I was able to delete all of the songs except for one. How do I delete the last one from my ipod? The song does not show up in iTunes when I plug my ipod into the computer.

    Recently, U2 music appeared on my ipod without my requesting it or wanting it. I was able to delete all of the songs except for one. How do I delete the last one from my ipod? The song does not show up in iTunes when I plug my ipod into the computer. The version installed on my ipod is 7.1.2(11D257).

    Hi donfrommars,
    Welcome to the Apple Support Communities!
    Please use the following article for information and instruction on deleting the U2 album from your devices and account.
    Remove iTunes gift album "Songs of Innocence" from your iTunes music library and purchases
    Have a great day,
    Joe

  • How do I remove the coloured bars from running down the side of my emails.

    How do I remove the coloured bars from running down the side of my emails.

    Hi
    The setting I have in Composing are-
    Composing
    Message Format - Rich Text
    In addressingonly have  tick in When sending to a group
    Responding - tick only the first two boxes
    Last only the bullet for Include selected text
    Hope htis helps

  • How do i remove the finder window from my start up desktop window.

    How do i remove the finder window from my start up desktop.

    Are you saying that when you log in, there are finder windows open before you even do anything? If so, that's because last time you logged out you left them open. Next time close all your finder windows before you log out and you should be good.

  • How can we remove the following zeros from quantity field ?

    Hi All.
    how can we remove the following zeros from quantity field while populating ALV by using FM REUSE_ALV_GRID_DISPLAY ?
    eg:getting output zqty = 2.000
    but i need           zqty = 2.
    help me to reslove this issue.
    Regards.
    jay

    Hi,
      While populating the field catlog do the following thing to   avoid zeros.
      wa_fieldcat-tabname = 'I_OUTPUT'.    " Curr
      wa_fieldcat-fieldname = 'FWAER'.
      wa_fieldcat-seltext_l = text-023.
      wa_fieldcat-no_zero = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR  wa_fieldcat.
    Thanks,
    Khushbu.

  • I had an iphone.  I have a new iphone and no longer use the old one.  How to do remove the old one from my icloud account?

    I had an iphone 4 on Sprint.  I switched to Verizon and purchased a 5S.  Kept the same phone number and affiliated the new phone to my existing icloud ID.  How do I remove the old device from my icloud ID? 

    and this if not already done
    iCloud: Remove your device from Find My iPhone

  • HT3702 how can i remove the authorization hold from my card...

    how can i remove the authorization hold from my card

    You can try contacting iTunes support : http://www.apple.com/support/itunes/contact/ - click on Express Lane, then iTunes > iTunes Store
    How much was the amount ? A 'normal' holding charge is a small amount (e.g. equivalent to about $1), and usually happens after you add or change credit card details on your account. Here in the UK it can take a few working days for it to disappear (so a weekend can extend the elapsed time).
    Edit : I don't know what a non-liability certificate is and/or whether Apple can do one.

  • I just installed Firefox 5. How can I remove the Bing search from the address bar? I don't want to see Bing at all.

    I just installed Firefox 5. How can I remove the Bing search from the address bar. I don't want to see Bing at all. I tired the Firefox options, right-clicking on the search field and the toolbar selection drop-down but could not find a way to get rid of that unwanted search window.

    *'''at the bottom of firefox''' there is a weird looking greenish circle with a lightning bolt in it*
    1. click it and hover over to '''PREFERENCES'''.
    2. click the second circle that say's '''BING.'''
    3. '''Un-check''' both boxes.
    4. you're done :)
    Note: it's not going to show the google symbol encrypt when you open a new tab it's just going to automatically use google as a search engine.

  • HT1277 how can i remove the email add from a deleted mailbox from the prompts of the 'from' field?

    how can i remove the email add from a deleted mailbox from the prompts of the 'from' field?

    Thanks a lot, roam! That worked

  • How can I remove the background sound from the headphone jack for my MacBoo

    for my MacBook Air problem adding music intensifier (Panasonic ST-HT1000) to give it an unpleasant sound background that sounds like a whiz, it's not so loud, but it is an unpleasant .. after a short time can get used to, but the fizz does not pass, however, believe that it is a big problem.
    Further I notice that when MacBookAir disconnected from the charger, it remains quieter sound.
    At first thought that the headphone jack (3.5 mm Headphone:
    Connection: 1/8-Inch Jack) or wiere have problem, but tried 3 different cables, but that does change enything, the problem remains.
    When I added iPhonu3GS playing - the background sound were not, then everything is OK!
    How can I remove the background sound from the headphone jack for my MacBook Air 13?

    There is no way to bring that up unless you have it typed in a document. You can use My Support Profile to find a list of serial numbers that have been purchased or registered with your Apple ID.
    http://support.apple.com/kb/HT2526?viewlocale=en_US 
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD  240G Vertex 3 SSD Boot HD 

  • How can I remove the moon phases from iCal?

    I need to remove ALL the moon phases that appear in iCal 5.0.3. Every time iCloud updates it sends 6 to 10 moon events to my MacBook Pro. Going forward 3 0r 4 months, there are too many moon phases. How can I remove the moon phases from iCal?
    I am on a MacBook Pro 2.2 with 4 GB using Mountain Lion 10.7.5.

    Try:
    items.RemoveAll(s => string.IsNullOrEmpty(s));
    Or you can filter them out using where:
    var noEmptyStrings = items.Where(s => !string.IsNullOrEmpty(s));
    Having fun with custom collections!
    Basics of .NET Collections in C#
    How does it work in C#? - Part 3 (C# LINQ in detail)
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • How can I remove the " Source.vi" from long Express VI Names?

    I am in the Moment working on the Development of an Express VI
    library for test purposes.
    How can I remove the " Source.vi" from long Express VI Names?
    This happens when the Express VI is inserted in the blockdiagram
    and listed in LabVIEW and TestStand Palettes.
    By short names like "DAQ-Assistent" or "EasyCalc" the string " Source.vi"
    is not shown at the end of the Express VI names.
    I used The Express VI Dev Toolkit 1.0 to create the Express VIs.
    Labview Version: 7.1 Base
    TestStand: 3.1
    It would be great to get the expert advice from the Forum for this issue!
    Thanks a lot.
    Andre

    I think I understand what you are asking for. If I am wrong, please try to explain it a bit more.
    The name shown may be different than the name of the vi file. To do this, your source VI and popup on its icon. From the short menu that comes up, select VI properties. In the top ring, select Window Appearance. The page that comes up lets you set various things that can affect the appearance of the VI. What you want to change is the window title. Uncheck the Same as VI name checkbox and change the string to whatever you want it to be.
    I hope that this helps,
    Bob
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • How can I remove the blocked contacts from skype h...

    Peace be upon you
    How can I remove the blocked contacts from skype home and all skype features?

    I found this solution and it worked.
    Paul B. Adams
    Re: safari 6.0 flash problem (blocked plug in) 
    Jul 26, 2012 7:39 AM (in response to defconnect5)
    I have a new MacBook Pro and I followed these instructions, downlonading and installing the new Flash plugin. But when I looked in "/Library/Internet Plugins" there was no folder called "Disabled Plugins".
    However, I did see two versions of Flash:
    _Flash Player.plugin with old date
    Flash Player.plugin with todays date
    I deleted _Flash Player.plugin and this fixed the problem.

  • How can i remove the shell case from cath kidston?

    Hi how can i remove the shell case from cath kidston

    Try:
    items.RemoveAll(s => string.IsNullOrEmpty(s));
    Or you can filter them out using where:
    var noEmptyStrings = items.Where(s => !string.IsNullOrEmpty(s));
    Having fun with custom collections!
    Basics of .NET Collections in C#
    How does it work in C#? - Part 3 (C# LINQ in detail)
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • How can I remove the blue background from my PDFs files

    How can I remove the blue background from my PDFs files

    Which tutorial?
    Answers are in your HTML and CSS code.  What is the link to your online test page?
    Nancy O.

Maybe you are looking for

  • Query doesn't pull data within Report

    Hi All, For some odd reason, I can run the following query against my informix database using DbVisualizer or Sql Editor just fine. But when I press F5 in Crystal report, I get nothing back. Any suggestions? SELECT     screenlog.user_id, screenlog.se

  • What are the steps to downlaod video from youtube?

    i wish to downlaod movies from youtube site but couldn't due to i am new on firefox website.

  • Is there any way to Integrate Sap b1 with microsoft project

    Hi, I would like to do add-on  Project Management. Before that I would like to get some idea from you experts Is there anyway  to integrate SAP B1 with Microsoft Project. I appreciate your help, and desperately need your help. Thanks in advance Regar

  • Brand new Canon 5d mark ii has dust inside of the LCD screen.. !!!

    Hello guys. I just received Canon 5d mark ii + 24-105mm lens kit in the mail couple of days ago. It's an amazing camera that will help to improve my work. I didn't want to use the camera until I received the screen protector and the UV filter to make

  • New iPhone for $200 less...

    I was annoyed to find out that the new iPhone is coming out for $200 less that I paid for mine. I feel taken advantage of!