Please need help to replace text in jtextarea

Hello!
I have a problem to solve under java, I would like to be able to replace a block of text by another in a Jtextarea
example
my text is presented like this:
part1
valeur=3
blah1 blah1 blah1
blah1 blah1 blah
part2
valeur=3
blah2 blah2 blah2
blah2 blah2 blah2
part3
valeur=3
blah3 blah3 blah3
blah3 blah3 blah3
my question is, how I could replace all the characters of part2 and part3 by the characters of the part1
is someone can help me while showing me an example of code in order to rule this problem
Thank you in advance.

This code seems to do what you want.
      JTextArea ta=new JTextArea();
      ta.setText("part1\nvaleur=3\nblah1 blah1 blah1\nblah1 blah1 blah1"+
             "\n\npart2\nvaleur=3\nblah2 blah2 blah2\nblah2 blah2 blah2"+
             "\n\npart3\nvaleur=3\nblah3 blah3 blah3\nblah3 blah3 blah3");
      int start=ta.getText().indexOf("part1");
      start=+6; //to get past part1\n
      int end=ta.getText().indexOf("part2");
      ta.select(start,end);
      String replace=ta.getSelectedText();
      start=end+6; //indexOf part2 plus 6
      end=ta.getText().indexOf("part3");
      ta.replaceRange(replace,start,end);
      start=end+6; //indexOf part3 plus 6
      end=ta.getText().length();
      ta.replaceRange(replace,start,end);
      System.out.println(ta.getText());

Similar Messages

  • Need Help in Replacement of Function Modules

    Hello all,
    I am working on Upgrade project from ECC 5.0 to ECC 6.0. I am facing problems for Replacement of two Obsolete Function Modules. Please give me a solution. FM's  are as follows.
    1) SET_AUTHORITY : This FM is obsolete in ECC 6.0 and there is not alternative FM present in help.sap.com or any other web portal.
    2) WS_QUERY : Here as per my knowledge we use class CL_GUI_FRONTEND_SERVICES and methods FILE_EXIST or DIRECTORY_EXIST as per the parameters in old FM. For parameter 'FS' we use 'FILE_EXIST' and 'DS' we use 'DIRECTORY EXIST'.
    But in our program prev. FM has parameter 'OS' i.e. Operating System.
    But there is not method called 'OS EXIST' or similar. Please suggest suitable method.
    Thanking you all in anticipation.
    Best Regards,
    Harish

    Hi Harish,
                       I too could not find any replacement for SET_AUTHORITY
    Obsolete Modules can be used in newer versions, but it is not supported by SAP in case of any technical issues.If you still need a replacement, you can replace it by the source code in the FM SET_AUTHORITY itself and modify according to your needs.
    Below is the source code of FM SET_AUTHORITY, so you can modify it according to your requirement.
      DATA: l_actvt  TYPE tact-actvt,
            l_hier   TYPE STANDARD TABLE OF sethier WITH HEADER LINE.
      CASE action.
        WHEN 'A    '.
          l_actvt = activity-add.
        WHEN 'C    '.
          l_actvt = activity-modify.
        WHEN 'D    '.
          l_actvt = activity-display.
        WHEN 'E    '.
          l_actvt = activity-delete.
        WHEN 'UD   '.
          l_actvt = activity-display.
      ENDCASE.
      CALL FUNCTION 'G_SET_TREE_IMPORT'
           EXPORTING
                no_descriptions  = 'X'
                no_rw_info       = 'X'
                setid            = set
                tabname          = table
                root_header_only = 'X'
           TABLES
                set_hierarchy    = l_hier
           EXCEPTIONS
                OTHERS           = 0.
      READ TABLE l_hier INDEX 1.
      IF sy-subrc <> 0.
        CLEAR l_hier.
        l_hier-shortname = set.
      ENDIF.
      CALL FUNCTION 'G_SET_AUTHORITY_CHECK'
           EXPORTING
                actvt  = l_actvt
                authgr = l_hier-authgr
           EXCEPTIONS
                OTHERS = 1.
      IF sy-subrc <> 0.
        CASE action.
          WHEN 'A    '.
            MESSAGE e827 WITH l_hier-shortname RAISING no_authority.
          WHEN 'C    '.
            MESSAGE e828 WITH l_hier-shortname RAISING no_authority.
          WHEN 'D    '.
            MESSAGE e829 WITH l_hier-shortname RAISING no_authority.
          WHEN 'E    '.
            MESSAGE e830 WITH l_hier-shortname RAISING no_authority.
          WHEN 'UD   '.
            MESSAGE e831 WITH l_hier-shortname RAISING no_authority.
        ENDCASE.
      ENDIF.
    If you need help in replacing in the above source code, please post your code here so that I can help you in modifying accordingly.
    Regards,
    Vasuki

  • Would like to trace my ipod touch because I was robbed. I would find it please. need help from you guys. Not because I am able to get another. Thank you.

    would like to trace my ipod touch because I was robbed. I would find it please. need help from you guys. Not because I am able to get another. Thank you.

    - If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    iCloud: Find My iPhone
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    - If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
    - Change the passwords for all accounts used on the iPod and report to police
    - There is no way to prevent someone from restoring the iPod (it erases it) using it unless you had iOS 7 on the device. With iOS 7, one has to enter the Apple ID and password to restore the device.
    - Apple will do nothing without a court order                                                        
    Reporting a lost or stolen Apple product                                               
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

  • I need help with my text tone and I have ring tone. no text tone for the 4s.

    I need help with my text tone. I have ring tone no text tone. I have a 4s.

        Hi Sarar2333!  Let's get your text tones working again!
    Here's a link with instructions how to enable and change your alert sounds for your text/notification settings on your iPhone 4S: http://vz.to/1stiF8a.  You can ensure text tones are enabled by selecting a tone in the "Text Tone" setting.  Let me know how that works out for you.  Thanks!
    AnthonyTa_VZW
    Follow us on Twitter @VZWSupport

  • I can't activate my desktop account. Error: E_AUTH_NOT_READY. Please, need help!

    I instaled my desktop Adobe Digital Edition, but I'm failing in activate it with my Adobe Id. The error code is:   E_AUTH_NOT_READY
    Please, need help!

    For this problem, you need to deauthorize and authorize ADE again.
    Launch ADE
    Help -> Erase authorization.
    ADE will be deauhorized.
    Now again AUTHORIZE ADE
    Help-> authorize computer.
    Error will be fixed !!

  • HT3702 error please need help

    Dears,
    I want pay for gems from clash of clan but the msg error please need help this problem take long time with me please please help me.
    Regards,

    If you haven't already done so then you can contact iTunes Support via this link and ask them why the message is appearing (we are fellow users here on these forums, we won't know why it's appearing) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Please, need help with a query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Take a look on the syntax :
    max(...) keep (dense_rank last order by ...)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
    Nicolas.

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Need help in printing text in footer

    Hi Friends,
    I need help from all you guys. I am working on SmartForms, and need help. Please look into the below situation, and appreciate if you can help me out.
    The Literal “**DATA CONTINUED ON NEXT PAGE**” is to be displayed at the bottom of the
      page in the Footer only if the data rolls onto second page.
    Thanks,
    Nikhil

    Hi,
    define the two variables in the global definition as
    g_cnt type sy-tabix.
    g_flg type c .
    ->in the initialization tab pass the internal table that is the main window.
    g_cnt = lines( the table name which you are using in the main
    window before the footer).
    Now you have the total no of lines in the g_cnt.
    in the loop which is in main window create the program line pass the output parameter as g_flg.
    in the condions tab give the condition as g_cnt = sy-tabix.
    in the source code of that program lines
    g_flg = 'X'.
    now for the footer where you are displaing the text coutinued on next page for in codition tab give the condition as g_flg = space.
    Thanks,
    NN.

  • Need help regarding converting text to Lines and Arcs.

    In my program i have text.Lets say the text is JAVA.
    Now i need to group that text(JAVA) in the form of line and arcs.
    Its like organizing lines and arcs and make it looks like a text(JAVA).
    Can we have such a possibilities to do that?
    Please help regarding this!!
    Thanks in Advance.
    Boopathy.

    Have a look at TextLayout class (http://java.sun.com/javase/6/docs/api/java/awt/font/TextLayout.html)
    Graphics2D g = ...;
    Point2D loc = ...;
    Font font = Font.getFont("Helvetica-bold-italic");
    FontRenderContext frc = g.getFontRenderContext();
    TextLayout layout = new TextLayout("This is a string", font, frc);
    Shape shape = layout.getOutline(null);
    Edited by: AlexeyUshakov on Sep 29, 2008 8:46 AM

  • Windows phone error code 80188301,. please need help

    i am getting an error while updating my windows phone.  windows phone error code 80188301,.
    please need help

    Hi,
    If issue persists after using the solutions provided by Aman Raizada, then I would suggest you ask the question in Windows Phone support forum:
    http://www.windowsphone.com/en-US/how-to/wp-support
    Regards
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Need help with automating text import/pasting/macro between Photoshop and Excel

    Hey everyone,
    I'm working on a large project now that seems extremely daunting, but I was hoping there would be some way to automate it using either Actions or some sort of macro program.  Here's the gist:
    I've created a template with 24 differently sized text boxes in the photoshop image file.  Each text feild has unique text that needs to be be pasted into it, which has been compiled in excel.  This wouldn't be too dificult to do, except I have to recreate this image and all 24 text fields aproximately 350 times.  None of the text boxes will remain static through all 350 images as text is the title, description, and demographic ratings/percentages/data for the topic of each image.  I did something similar manually last year and it took me about 3, non-stop 18 hour days to complete it.
    (the test template)
    Can anyone think of any way I could automate this process?  I'm thinking some sort of macro that copies cell 1 in excel, switches to photoshop, opens layer 1, pastes, switches back to excel, goes to cell 2, copies, back to photoshop, layer 2, pastes, etc, etc, then does a 'save as' in photoshop and revets to PS layer 1, EX cell 1 (on tab 2) to start the process all over again.  I have no idea if this would work or if there is another way to do this but I would really appreciate any help or advice you guys could give.  I don't have really any expreience using PS Actions or macro programs/scripts, so I may be over my head or overlooking a really simple way to do this.  If there's a way to do it, I'm persistent enough to figure it out and get it working. Doesn't really matter how it gets done, I just need to fill those text boxes as best as I can and as quickly as I can.
    Any help you all could give is really appreciated.

    Have you read up on the Variables support in Photoshop?

  • I need help getting my text tones???

    i need help getting my purchaced text tones to my new iphone

    Where did you bought it?
    What device did you used to obtain them?

  • Please need help in ora-03134

    Good Day
    i'm using oracle database Release 10.2.0.1.0 and need to connect to release 8 when config the Net Configuration Assistant and connect to sql*plus error ora-03134 ,then download patch 10.2.0.5.0 PATCH SET FOR ORACLE DATABASE SERVER and the error still existing .
    Please i'm not want to upgrate release 8
    Please need help

    Hi,
    could you check
    http://forums.oracle.com/forums/thread.jspa?threadID=855541
    *Bug 3437884 - 10g client cannot connect to 8.1.7.0 - 8.1.7.3 server [ID 3437884.8]*
    Edited by: CKPT on Aug 20, 2010 3:45 PM

  • Why it won't let me install key please need help

    I bought this photoshop elements yrs ago and have never used it would like to try it now but am hoping it is compatable w/my new pc HP touch screen 520-1070 also why wont it let me install registration key please need help

    First try going to appleid.apple.com and reset your password.
    After resetting you password, log into your account, at same site and go to manage my account.
    Verify any info on account. Add/remove any relavant data. Remove any duplicate email address, make sure you have an additonal email aside from your apple id.
    After verifying all this info, try accessing the app store with new password to update apps.
    If unable to at this point and you can verify your identity with the serial number of a apple product registerd to you, verify your apple id, and the billing info on your account; you can call support at 1-800-APL-CARE and ask to speak to account security to reset security questions.

Maybe you are looking for

  • SP14 Multi-mapping - error in receiver idoc adapter

    Hi, I have a scenario where a business service should send some XML to SAP CRM. I get the file via a sender JMS adapter and try to post it to CRM via a receiver IDOC adapter. I have created a multimapping (1:N - 1 XML file to many Idocs) as should in

  • Boomy sound from apple tv

    Can somebody please help? I have just purchased ATV and finally got it synced (after 3 days of port 3689 error msg) only to find that it sounds shockingly bad, very boomy and not clear at all. ATV is connected to samsung tv via HDMI and then to samsu

  • How to display XML document

    Hello All. I am using Apex 3.0.1.x. I've uploaded an XML file into an XMLTYPE column in a table and am now trying to display this XML data in an Apex report region. I saw a beautiful example of doing this in Denes Kubicek's wonderful demo app 31517,

  • Finder not showing previews of Canon 5D Mark II raw files?

    I've updated to Mac OS 10.5.7 but the Finder is still not showing the previews of Canon 5D Mark II raw files. This is on a Mac Mini with 1.83 GHz Intel Core 2 Duo. Any help would be greatly appreciated! (Interestingly, I have another Mac Mini with 1.

  • Does itunes have any plans where u pay by the month?

    i was wondering if itunes has any plans where i pay by the month an get unlimited music,apps,etc?