Hello all from javaDumb! I'm in my first java class and this is my first post so please be patient. I'm suppose to use StringTokenizer to search a document and replace some text, but the book for this course only explains how to print the text to the screen as tokens. I have created a class called editor with two constructors; one that has no parameters and one that passes one parameter(the document to be searched). I also have methods for getDocument(), setDocument(). This project also calls for two overloaded methods called replace(), one passes (search text, replace text) and the other passes (document, search text, replace text). I don't know how to use these and StringTokenizer together.

Any help would be appreciated.

Hello all from javaDumb! I'm in my first java class and this is my first post so please be patient. I'm suppose to use StringTokenizer to search a document and replace some text, but the book for this course only explains how to print the text to the screen as tokens. I have created a class called editor with two constructors; one that has no parameters and one that passes one parameter(the document to be searched). I also have methods for getDocument(), setDocument(). This project also calls for two overloaded methods called replace(), one passes (search text, replace text) and the other passes (document, search text, replace text). I don't know how to use these and StringTokenizer together.

Any help would be appreciated.

u can read the whole amount of text in doc together and

pass it to u r fun. ther u can use stringtokenizer to get each string from ur
whole content string and den u can use replace fun of string

Thank you tigerxx for the reply, but I'm still quite lost on how this is done.

Hi everyone,
I am currently trying to do what you are doing now
see this thread

http://www.daniweb.com/techtalkforums/thread14899.html

but the thing is that function that i wrote only runs perfectly once and it can't search
anyting after calling that function.

It's really weird but you can use that function if you like and if you happen to be able to find solution to my problem please let me know as i really need help for that

Yours Sincerely

Richard West

I'll give it a try freesoft_2000, will let you know if i have any better luck.

Thank you,

Kevin Ervin

hi everyone,
Kevin i managed to do it. Firstly do not pass the pos1(the Jtextpane's current position) into the function but read it inside the function. That's why my function was working only once as i was always reading the same position. By the way if you are using a dialog make sure it it not modal and always to grab the focus of your text component.

Yours Sincerely

Richard West

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.