Amicuk Programming Answers

Please need help to replace text in jtextarea

-0001-11-30   Views:0


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

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
my text is presented like this:
blah1 blah1 blah1
blah1 blah1 blah
blah2 blah2 blah2
blah2 blah2 blah2
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.

The replay answer
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");,end);
      String replace=ta.getSelectedText();
      start=end+6; //indexOf part2 plus 6
      start=end+6; //indexOf part3 plus 6

Go to See the other 3 answers

Please need help to replace text in jtextarea

Category:DefaultRelease time:-0001-11-30Views:130

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[More]

How to print diffrent color and diffrent size of text in JTextArea ?

Category:DefaultRelease time:2015-10-11Views:130

Hello All, i want to make JFrame which have JTextArea and i append text in JTextArea in diffrent size and diffrent color and also with diffrent fonts. any body give me any example or help me ? i m thanksfull. Arif.You can't have multiple text attribu[More]

Use VBA and Excel to open Dreamweaver HTML (CS5), find and replace text, save and close

Category:DefaultRelease time:2015-10-11Views:130

I wish to use VBA and Excel to programmatically open numbered Dreamweaver HTML (CS5) and find and replace text in the code view of these files, save and close them. I have  5000 associations between Find: x0001 and Replace: y0001 in an Excel sheet. I[More]

Trouble with "add note to replace text" annotation

Category:DefaultRelease time:2015-10-11Views:130

When I use "Add note to replace text" in Reader XI, the note acts as if it is locked even though it is not. The Locked box is not checked, but yet the options are grayed out; and I cannot delete the note, though I can edit the text box. "St[More]

Applescript: open Pages doc from Templete, change filename and replace text

Category:DefaultRelease time:2015-10-11Views:130

Hi! I just got started with applescript and i want a script that does the following: 1. open "choose from list" dialog to choose the topic of my document from 4 possibilities (here for example A, B, C, D) 2. open document from TemplateXY 3. set[More]

Folder action to find and replace text and change line feeds

Category:DefaultRelease time:2015-10-11Views:130

I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files. The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes) This text has to be removed[More]

Find and Replace text string in HTML

Category:DefaultRelease time:2015-10-11Views:130

Opps... I hope this forum is not just for Outlook. My Html files reside on my hard-drive. I am looking for VBA code to open specified file names ####File.html and then find and replace text strings within the html for example "####Name" replaced[More]

Find and replace text in multiple Photoshop files?

Category:DefaultRelease time:2015-10-11Views:130

Hi there, Let us say I have six Photoshop files: 1.psd, 2.psd, ..., 6.psd. All of these files contain the word "LoremIpsum" in random text layers, within each document. Is there a way I can search for "LoremIpsum" in all documents and[More]

Replacing text in a text file with special characters

Category:DefaultRelease time:2015-10-11Views:130

Hi all, in my test text file i found an interesting issue, where i can't replace text that looks something like this "New Text Document - Copy (2).txt" (gc $logeps)|foreach{$_ -replace "$($",""}|Out-File $logeps the[More]

Replace text in photoshop document & save

Category:DefaultRelease time:2015-10-11Views:130

Hello, I have to make apprieciation certificates for a committee. Is there a way to use Automator to replace text within a photoshop document (people's names) and then save each name in a different file? Thanks!In theory, at least, this should be pos[More]

Search & replace text programmatically in pdf file

Category:DefaultRelease time:2015-10-11Views:130

I need to search & replace text programmatically (preferably in .NET c#) in existing pdf file. Does anyone know how to do it (maybe with with Acrobat SDK) ? Thanks in advance! A. PS: Well done working example :-)Searching APIs are provided, but there[More]

I want 3 separate, distinct Firefox home pages for each of my 3 email accounts to be open at the same time.Questions are typically followed by a question mark. My answer answered your question. Firefox doesn't do email, so there are no "Firefox email [More]
Hi, I'm using SSAS cube as a source for my webi report .Some report need custom sorting for hierarchy object , we are not able to apply sorting correctly in webi. What do i need to do in order to apply the custom sorting for hierarchy object?  Thanks [More]
Hi, just a quick crapshoot here. With the increased permission levels given to AIR applications, will it become possible to embed video playback codecs in an application? Thanks.Hi, It won't be possible to embed video playback codecs in AIR.Read othe [More]
Hi, when i am trying to save the purchase order after changing ( delete the item) in me22n the system provide the error message related to version(ie header data still have faulty) if i complete the version manually then the system allow to post the [More]
I cant seem to open the preview, app store, updates, quicktime, calander,ibooks, facetime the list goes on ... Running Mavericks 10.9.2 and latest itunes. Any ideas?Boot into recovery mode, launch Disk Utility, select the boot volume, repair permissi [More]
There is a column under the Order tab in the Supply/Demand form in ASCP that is titled INTERNAL SALES ORDER. The assumption is that this would in fact be the internal sales order number from the supplying inventory organization. However it comes in n [More]
In Firefox I log on to EBAY. Any item that I call up does not display the description nor did IE 8. I upgraded IE 8 to IE 9 and EBAY now works in IE 9.I have set off the forged wed site message. I have installed latest Firefox, Realplayer and Flash p [More]
Hi, I allways liked Adobe Flash for websites but I wonder if it's a good descission to use it these days. Many vendors for tablets and smartphones do not support it. I'm currently setting up an online busines ( but I'm he [More]
Bonjour , j'ai pris l'abonnement Créative Cloud et j'ai téléchargé l'application Illustrator . Le téléchargement c'est bien éffectué mais quand je veux me servir de l'application et que je l'ouvre ça se referme directement . J'ai beau répéter l'opéra [More]
Bonjour. J'essaie d'installer ma version Premiere Pro V7 sous Win 8.1 (64). Message d'erreur: "Adobe Premiere Pro ne parvient à installer aucun pilote audio. Réinstallez Premier Pro puis recommencez". Quelqu'un aurait-il la solution [email protected]  [More]