I have assigment to make notepad using NetBeans Java. I already made the whole thing, I just don’t know how to implement find/replace dialog, can you help me with this. I’m using jTextArea.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I will assume that you already know about Swing and how to make the appropriate dialog box (since you apparently have already made the
JTextAreafor the Notepad equivalent), and that you just want to know how to make it work on the back end.What I would do is have a
Scannerobject go through your file to perform the find and replace.You can use
.equalsIgnoreCase()if case doesn’t matter. Likewise, you can tweak to adjust to your user parameters (i.e., if it doesn’t have to match the whole word, use.contains()instead). There may be some nit-picky other things you need to do to maintain abnormal spacing and line breaks, but this is the general approach I would use.