CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    find string in Jtext area

    i want to search a string in my JTextArea,but i m not able to find ne solution,what shud i write after dis code to search a string...pls help me solve dis out..





    JTextArea logTextArea;
    StringBuffer buffer=new StringBuffer(); /*it contains some random content appended in previous part of program... */
    logTextArea.insert(buffer.toString(), logTextArea.getText().length());

  2. #2
    Join Date
    Jan 2009
    Posts
    596

    Re: find string in Jtext area

    I'm not sure exactly what you are asking. Could you please rephrase your question to make it clearer? What does 'search a string in my JTextArea' mean?

    I would also advise using real English words, not text-speak. We are not all native English speakers. Bad spelling means you are putting unnecessary obstacles in the way of potential answerers, which in turn means a lot of people will just ignore your question.

  3. #3
    Join Date
    Nov 2011
    Posts
    189

    Re: find string in Jtext area

    Well, having known the string you're looking for it's pretty easy.
    Textareatext=textarea.getText();
    Int firstIndex = textareatext.indexOf(stringToLookFor,0);
    Int lastIndex = firstIndex+stringToLookFor.length();

    And now you pretty much have the starting and ending positions of your string... Is that what ur Asking?

  4. #4
    Join Date
    May 2009
    Location
    Lincs, UK
    Posts
    298

    Re: find string in Jtext area

    Quote Originally Posted by cens View Post
    Textareatext=textarea.getText();
    Int firstIndex = textareatext.indexOf(stringToLookFor,0);
    Int lastIndex = firstIndex+stringToLookFor.length();
    What language is that?
    Integers in Java are either int or Integer, not Int (Java is case sensitive). Also Textareatext != textareatext.

  5. #5
    Join Date
    Nov 2011
    Posts
    189

    Re: find string in Jtext area

    blame it on the auto-UpperCase my phone has
    I know it's case sensitive, but by the way...was this what you were looking for, dilesh?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured