Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:11:06+00:00 2026-05-29T22:11:06+00:00

I want to write a program, which search some HTML addresses. I assume that

  • 0

I want to write a program, which search some HTML addresses. I assume that one search will be going more than 1 minute. When I print the results to console everything is OK, but when I make a frame the results don’t appear in textpane. Now I have two classes one to search and one for frame. I write the simply function in the frame class to check if adding text working:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String Txt=(String)jComboBox1.getSelectedItem();
    jTextPane1.setText("");
    addText(Txt);    
    SecondClass.find(Txt);
}
public void addText(String text){
    StyledDocument doc = jTextPane1.getStyledDocument();
    try{
    doc.insertString(doc.getLength(), text, null);
    }catch(Exception e) { System.out.println(e); }
}

And in SecondClass I write the same line to addText, but it is working only from frame class. The second problem is that if the search is going I cannot do anything in program and the text from frame class is see after search is finished. I want see text immediately after finding it like in console which is working and I want to have possibility to click this link before search is ended ( I don’t implement clickable links yet and don’t know how to do this). I think that I must synchronize the processes, but I don’t know how to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:11:08+00:00Added an answer on May 29, 2026 at 10:11 pm

    It sounds like you are doing the main downloading task on the special Swing event thread, which handles all the work for Swing components. This will prevent the GUI from responding properly.

    This will happen ‘by accident’ if you do long-running actions within event handlers (e.g. when you press a JButton).

    You need to do long-running tasks in a separate thread, then ‘hand over’ the data to the Swing thread to update the GUI, using SwingUtilities.invokeLater(runnable); Edited: or see Max’s answer about SwingWorker.

    For example, your worker thread would do something like this when it has some data ready, using an anonymous Runnable:

        final String text = getText();
        SwingUtilities.invokeLater(new Runnable()
        {           
            @Override
            public void run()
            {
                appendText(text);                
            }
        });
    

    where getText() just indicates some means of acquiring the downloaded text, and appendtext() is a method you will need to write to update your textpane.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a program preferably Servlet that will search the particular keyword
I want to write a program in which plays an audio file that reads
I want to write a program in C/C++ that will dynamically read a web
I want to write a C program that can search Bonjour enabled devices on
I want to write a program which downloads some data from Internet (PC part)
I want to write an program which can find some metainformation of mediafile. I'm
I want to write a program which will print a string every second on
I want to write a program which will read in a whole bunch of
I want to write an Ada program which replaces Latin1 characters with applicable HTML
I want to write a simple program which shows my internet activity over a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.