JInternalFrame - search text?

Posted on 2009-04-27
Last Modified: 2013-11-23
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

Question by:allelopath
    LVL 17

    Accepted Solution

    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.
    LVL 92

    Assisted Solution

    u can use the following to locate the index of the search string in the text

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

    LVL 92

    Expert Comment

    LVL 1

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Title # Comments Views Activity
    tenRun challenge 28 67
    scoresIncreasing challenge 10 48
    IT Company 5 54
    strCopies  challenge 17 60
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now