Hi all .hope all is well ..A quick trim question

Hi all
Hope all is well ......
I have a quick trim question I want to remove part of a string and I am finding it difficult to achieve what I need
I set the this.setTitle(); with this
String TitleName = "Epod Order For:    " + dlg.ShortFileName() +"    " + "Read Only";
    dlg.ShortFileName();
    this.setTitle(TitleName);
    setFieldsEditable(false);
[/code]
Now I what to use a jbutton to remove the read only part of the string. This is what I have so far
[code]
  void EditjButton_actionPerformed(ActionEvent e) {
    String trim = this.getTitle();
      int stn;
      if ((stn = trim.lastIndexOf(' ')) != -2)
        trim = trim.substring(stn);
    this.setTitle(trim);
[/code]
Please can some one show me or tell me what I need to do. I am at a lose                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

there's several solutions:
// 1 :
//you do it twice because there's a space between "read" and "only"
int stn;
if ((stn = trim.lastIndexOf(' ')) != -1){
    trim = trim.substring(0,stn);
if ((stn = trim.lastIndexOf(' ')) != -1){
      trim = trim.substring(0,stn);
//2 :
//if the string to remove is always "Read Only":
if ((stn = trim.toUpperCase().lastIndexOf("READ ONLY")) != -1){
   trim = trim.substring(0,stn);
//3: use StringTokenizer:
StringTokenizer st=new StringTokenizer(trim," ");
    String result="";
    int count=st.countTokens();
    for(int i=0;i<count-2;i++){
      result+=st.nextToken()+" ";
    trim=result.trim();//remove the last spaceyou may find other solutions too...
perhaps solution 2 is better, because you can put it in a separate method and remove the string you want to...
somthing like:
public String removeEnd(String str, String toRemove){
  int n;
  String result=str;
  if ((n = str.toUpperCase().lastIndexOf(toRemove.toUpperCase())) != -1){
   result= str.substring(0,stn);
  return result;
}i haven't tried this method , but it may work...

Similar Messages

  • Hi All, ready for a quick mask question from a newbie ;-) ?

    When I make a quick mask selection, it becomas "red-ish" as it suppose to. When I leave quick mask mode however, the painted area does not become a visible (yes I checked the correct option dialogue box, I guess, according to a friend) selected area though. But when I make any adjustment, eg color saturation, it only affects the area I selected in the quick mask mode, which I cannot see except for the adjustment. How on earth did I manage to make this happen. What have I done wrong or haven't done at all? You kind attention and quick reply is highly appreciated. Best /Stefan

    Thanks a lot, Sir, much appreciated. Under View options one can selected "show selection outlines or boundaries", well not in swedish, it says something completely different, but just as you said, there it was!
    Again, thanks a lot!

  • Slipknots All Hope Is Gone album not avaliable for pre order in Australia

    I have recently gone onto the iTunes store to pre order the new Slipknot album All Hope Is Gone. I was dissapointed to find that it was not avaliable for pre order in the Australian iTunes store. Does anyone know if it will become avaliable for pre order before its release or can i pre order it from the American store?

    Does anyone know if it will become avaliable for pre order before its release or can i pre order it from the American store?
    I doubt anyone here will know before such time as Apple posts it on the iTunes Store, should that occur. Apple is often unable to negotiate rights to pre-release content on all countries, so it may well not be avaiable for pre-purchase.
    As to ordering from the US iTunes Store, no, you can't, not unless you have a US credit card (issued in the US and with a billing address there).

  • My iphone 4 fell in the toilet 4 days ago and it's been drying in rice since.  now when i plug it in, the screen remains black  but it will vibrate.  is this a good sign or is all hope lost for getting it to work again?

    My iphone 4 fell in the toilet 4 days ago and has been drying in rice ever since.  I tried plugging it in today and the screen remained black but it did vibrate when i switched it to vibrate.  Is that a good sign?  Or should I just give up hope already?

    well good sign or good sign maybe a strong word
    it mean that not all of the device have been damaged by the fluid
    but it does not really mean that the screen will ever work again
    when drying in rice make sure you don't
    1 conceal it so the vapor can't escape or it will not dry enough
    2 make sure to leave in on a heating source like a heated floor or radiator to speed up the proccess of the vaporising

  • HT1351 I have a apple ipod touch but recently I restored all the settings, as well as the applications. But now I am not able to add songs to it. There is blank screen that shows the symbol like to connect to itunes first. I'm not able to use that... Plea

    I have a apple ipod touch but recently I restored all the settings, as well as the applications. But now I am not able to add songs to it. There is blank screen that shows the symbol like to connect to itunes first. I'm not able to use that... Please help

    The iPod's firmware is corrupt. You'll need to restore it again in iTunes. If necessary, place the iPod in recovery mode for iTunes to recognize the device. Use the instructions in this Apple support document to walk you through the process of placing the iPod Touch into recovery mode.
    iOS: Unable to update or restore
    B-rock

  • I am unable to Send E-mail via Default mail app in my iphone. IOS7, i have account of icloud, Gmail, Microsoft all the account are well added, i can recieve e-mails but the massage i send is never sent

    I am unable to Send E-mail via Default mail app in my iphone. IOS7, i have account of icloud, Gmail, Microsoft all the account are well added, i can recieve e-mails but the massage i send is never sent

    Turns out this was a simple set up error for me, although i'd set up mobile me to sync my e mails I had never set up my outgoing message server. Therefore, if I received a message from me.com I could reply no problem, however if the message came from aol.com I couldn't reply.

  • In iTunes heb ik afspeellijsten met muziekvideo's. Na synchronisatie komen de namen van deze lijsten op mijn iPod met de mededeling dat de inhoud uit 0 nummers bestaat. Alle muziekvideo's zijn wel onder de app "video's" gezet. Dit na de upgrade naar ios6.

    In iTunes heb ik afspeellijsten met muziekvideo's. Na synchronisatie komen de namen van deze afspeellijsten op mijn iPod met de mededeling dat de inhoud bestaat uit 0 nummers. Alle muziekvideo's komen wel onder de app "Video". Het probleem is ontstaan na de upgrade van iOs 6. Heeft iemand een oplossing?

  • I seem to have used up all my broadband (huge amount) very quickly with my iphone - is there anything in the settings of my iphone that I may have set up incorrectly to make this happen ?   As cannot see it is possible to use this much.

    I seem to have used up all my wi-fi broadband extremely quickly (I have huge broadband limit) using my iphone, and not sure if I have something incorrectly set up in the settings of my iphone that has allowed this to happen?  Any ideas?   Haven't been watching any movies or downloading anything major.

    Hickeysm,
    Do you mean your the download limit set by your Internet Service Provider for all broadband use? Or the data allowance from your phone network provider for your iPhone?
    If you mean the phone contract's data allowance, I have a similar problem. I had a message from O2 yesterday to say I've used 80% of my monthly data allowance, which is very unusual for me. I may have found the cause which is that my iPhone is reluctant to connect to Wifi, and when it does, no data moves; so it's been accessing data with 3G. Nothing wrong with my wifi (iPad and iMac connect without problems).
    I'm suspecting the iOS 5.1 update. Has anyone else had similar problems since taking it?

  • Should i "Remove All Website Data" as well as clear Cookies and Data off my iPad

    Should I "Remove All Website Data" as well as Clear Cookies and data?

    Not for normal everyday use.
    Would you have a specific reason to do so?  If not, don't bother.

  • Help! My iPhone 4 was stolen, and it is in iOS 7, will the phone still be used? Or if they reformat it, my files would be deleted? I hope all my files will be deleted. Thanks for your help. :)

    Help! My iPhone 4 was stolen, and it is in iOS 7, will the phone still be used? Or if they reformat it, my files would be deleted? I hope all my files will be deleted. Thanks for your help.

    Hey ChrisJ4203, thanks for answering buddy , I still have a question.
    I have a passcode for my iPhone, but I don't have the application Find my iPhone. Can I retrieve my photos, notes, reminders and all other data in my iPhone, I mean, if I bought another one, and connect it to my computer and go to iTunes then restore backup, cause I backup my iPhone last Oct 10, 2013, will I recover all the details in my iPhone that was stolen? It's like I'm still using my old iPhone's apps but with a new iPhone. Thanks.
    -Alfonso Santos

  • My iPod was stolen a long a few months ago and I've given up all hope in finding it. I have never purchased item on iTunes, and I think the iCloud might have been deleted. It doesn't show up in "My products" either.

    My iPod was stolen a long a few months ago and I've given up all hope in finding it. I have never purchased item on iTunes, and I think the iCloud might have been deleted. It doesn't show up in "My products" too and I tried Find My iPhone.

    No. Apple won't do anything without a court order. Since it wasn't upgraded to iOS 7 before it was stolen then there's nothing you can do. You could file a police report with your serial number but there may be a small chance.

  • TS4268 When my daughter uses facetime and imessage on her ipod, her father gets all the messages as well on his mobile phone.  How do I stop that.

    When my daughter uses facetime and imessage on her ipod, her father gets all the messages as well on his mobile phone.  How do I stop that.

    See Here...
    setting-up-multiple-ios-devices-for-messages-and-facetime.html

  • HT201320 in setting-mail,contacts,calendars, all my accounts as well as Add Account shows in grey, non activated. Any suggestions?

    in setting-mail,contacts,calendars, all my accounts as well as Add Account shows in grey, non activated. Any suggestions?

    Hey Jeremy,
    From the Enterprise Deployment Guide:
    +Important: When you configure a device to sync with Exchange, all existing calendar+
    +and contact information on the device is overwritten. Additionally, iTunes no longer+
    +sync contacts and calendars with your desktop computer. You can still sync your device+
    +wirelessly with MobileMe services.+
    +To change how many day’s worth of data is synced to your device, go to Settings >+
    +Mail, Contacts, and Calendars. The default setting is three days.+
    http://support.apple.com/manuals/enUS/Enterprise_DeploymentGuide.pdf
    You can leave iPhone related feedback and feature requests here: http://www.apple.com/feedback/iphone.html
    Jason

  • My apps wont update! App store says I have 20 updates, when I click update all, they all go in to "Waiting" mode and its been like that for 24 hours now with no sign of updating. Do I have to delete them all and reinstall ?

    I updated my iOS system 2 Days ago. App store says I have 20 updates, when I click update all, they all go in to "Waiting" mode and its been like that for 24 hours now with no sign of updating. Do I have to delete them all and reinstall ? any help much apreciated.

    Snafujafo wrote:
    Dear ED3K:
        First:  I hope you don't work for Apple as you have some poor communication skills in assistance. That said, I would never in a million years pay you 45 dollars to help me. I think I would sleep with Satan first!!
    No one here works for Apple. This is a user-to-user technical support forum. Everyone here is a volunteer. You tend to get from this forum what you bring to it. If you come in ranting and raving and saying you're going to throw your iPhone out the window and that Apple is mean, people are not likely to respond to you with sweetness and light and puppies and kittens.
    If you really want help, I'd suggest you take a deep breath and then start a new thread in which you explain the problems you're having, the steps you've taken to resolve the problems, any error messages you've gotten. Stick to the facts. Check the attitude and emotion at the door. People will do their best to help you.
    Best of luck.

  • Dashboard - displaying a widget on top of all windows all the time

    Seems that I remember in previous versions of Dashboard, you could get it to show selected (or all) widgets all the time. Call it "on the desktop" or "on the top level" or whatever, but you didn't have to enter the expose-like environment to interact with a widget.
    Is there a way to do this or am I missing something or did they take this away in the later version(s) or ...??
    Widgets have been more of a novelty to me as I haven't really had a need for widgets until now. I have one widget that I'd like to have shown all the time on my second monitor as, well, as a dashboard display. But I need it there all the time.
    I also seem to remember using a 3rd party util that provided another way to do this, but all the ones I've just looked at and tried don't offer that desktop-level functionality.
    Thanks much in advance!!
    SA
    Dual 1GHz G4   Mac OS X (10.2.x)  

    I may have just answered my own question.
    Seems there's a wiki on it (you'll have to copy/paste this link):
    http://en.wikipedia.org/wiki/Dashboard_(software)
    It involves hitting (and holding down) the hot-key for Dashboard (F12 unless you've changed it in the sys prefs), dragging the widget you want and then releasing the hot-key. When released, you should still be dragging the widget and it should remain floating on the desktop.
    In addition, there's a command-line terminal hack for developers which will apparently make this permanent, although I haven't verified this yet:
    defaults write com.apple.dashboard devmode YES
    It seems to be working for me so far. Anyone care to verify this?
    Thanks again!
    SA

Maybe you are looking for