I m doing a project using eclipse plugin to create a IDE.
I have a view which consists of a textbox,when i enter some text in it and press the add button the text should replace a particular string in the editor.
I m able to find the current editor but i dono how to find the position of the string to be replaced.
Can anyone help me in doing this?
Rather than do this yourself, wouldn’t it be easier to use
String.replaceFirst()orString.replaceAll()to do the replacement?All you’d need to do is “get” the current text
Stringfrom the target editor, do the replacement and then “set” the resultingStringback to the target editor.I’m not familiar with Eclipse, but most text fields will probably implement an abstract class like
JTextComponentwhich has handy methods togetText()andsetText().