Sitemap

Amicuk Programming Answers

Please need help to replace text in jtextarea

-0001-11-30   Views:0

Advertisement

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

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.

The replay answer
Advertisement
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());

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 "$($file.name)",""}|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]

Hot
Hi all, I bought a HP Envy 100 eAll-in-One (CN517A) D410A in 2011 when I was living in the US. I always used HP60 cartridges without any problems while in the US. In 2013 I was relocated to Europe (Luxembourg), and recently my last supply of US-bough [More]
Hi, My Front Ends has started to sing a song like: Log Name:      Lync Server Source:        LS Outbound Routing Event ID:      46046 Task Category: (1038) Level:         Error Description: A call to a PSTN number failed due to non availability of ga [More]
Wer kann mir helfen? Ich habe Adobe Photoshop 2.0 Starter Edition und habe mir meine fotos von der Festplatte in Photoshop Album geladen. Jetzt bekomme ich diese nicht auf Festplatte zurück. Kann diese auch nicht bearbeiten, mailen oder drucken. Zusä [More]
how to get the itunes code of iphone 5s I am from india .... the itune setting doesnot give me none option in my phone .... And i dont know the itunes gift code ... So pls give me the detail how to get the itunes code and what is it ?It would have be [More]
Since upgrading to Mavericks my Adobe Acrobat 9 Pro requires administrative password on every launch which seems like an unnecessary step.  Does anyone know why this is happening and what can be done to eliminate this?Download and run the combo updat [More]
I have developed a form in Adobe pro which I want to use the extra fields that are available in Form Central such as ranking. I can create a form with these extra fields but cannot edit it once saved. Whats the trick?Hi; This FAQ describes how to fur [More]
Hi experts, I not able to download the user group , infoset and query through standard program RSAQR3TR, even though the user group, infoset and query exists. i. e with download option in RSAQR3TR prgram. so, can u please guide what exactly might be [More]
So. I have 1 DNS server, 1 DC, 1 GC etc. One. It essentially is a lightweight network only serving a few PCs. Strangely it is getting these events for a DNS that doesn't exist. The dynamic registration of the DNS record '_ldap._tcp.pdc._msdcs.araropr [More]
 Hi everybody, I have been watching this debate with interest. I encountered similar situation and realised that even after calling the method ReleaseDistReference on DistObjectMgr, the object is live ( Probably some time before garbage collection ki [More]
very urgent help needed. Scenario: 1. My proxy service (new wsdl based) calls business (legacy wsdl based). 2. I want to transform input format from new format schema to legacy format schema. 3. I write a Xquery and Replace ./* in variable body with [More]