JInternalFrame - search text?

In my application, I display the log file using an JInternalFrame (assume textArea has stuff in it)
A user has requested the ability to ctrl-F in order to search.
Is there another class I can use to do this?


JScrollPane scrollPane = new JScrollPane(textArea);
JInternalFrame internalFrame = view.getDataPanel().createInternalFrame(scrollPane, "Log File");

Open in new window

LVL 1
allelopathAsked:
Who is Participating?
 
Thomas4019Connect With a Mentor Commented:
I dont think there is a built in java component for searching like that. One alternative you could do is write the log to a temporary HTML file. Then auto open the HTML file locally in the users web browser. Then they have all the functionality their web browser has. This would only work for an application and not for applets of course. To write the file i would use PrintStream, and then to open the file i would use java.awt.Desktop.
0
 
objectsConnect With a Mentor Commented:
u can use the following to locate the index of the search string in the text

int index = textArea.getText().indexOf(searchString);

0
 
objectsCommented:
0
 
allelopathAuthor Commented:
Thanks for your replies. I ended up using Thomas4019's suggestion. I used BufferedReader/Writer which reads/writes line-by-line. Based on the contents of the line, I could add html tags, like color, to the line.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.