replace range still not working!

I cannot get replaceRange to work properly on a textArea, with words longer or shorter than the word i want to replace it meeses it all up! here is my code:

EditReplaceMenuItem.addActionListener(new ActionListener(){//action listener for "replace" menu item in edit menu

publicvoid actionPerformed(ActionEvent e){

String replace = JOptionPane.showInputDialog(null,"Replace:");//find word to replace

String with = JOptionPane.showInputDialog(null,"With:");//get word to replace with

int index = jtp.getSelectedIndex();//get selected tab index

JTextArea textArea = textAreas.get(index);//get textarea coreesponding to tab

String text = textArea.getText();//get text from that textarea

//replace code

int startIndex = 0;

Scanner scan =new Scanner(text);

while(scan.hasNext())

{

String current = scan.next();

if(current.equals(replace))

{

int start = text.indexOf(replace, startIndex);

int end = start + replace.length();

textArea.replaceRange(with, start, end);

}

startIndex += current.length();

}

}

});

here is a series of scrennshots which may help you see my problem : )

http://i41.photobucket.com/albums/e254/frahasio/howstrange.jpg

please help!

[2124 byte] By [boblettoj99a] at [2007-11-26 18:56:01]
# 1
Is there a particular reason why you're not usingreplaceAll(String regex, String replacement)which is defined for Strings?#
duckbilla at 2007-7-9 20:34:42 > top of Java-index,Java Essentials,New To Java...
# 2
ah yes there is a very good reason: i didnt know about it!hahahaha, thank you for the enlightenment!
boblettoj99a at 2007-7-9 20:34:42 > top of Java-index,Java Essentials,New To Java...