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 9303897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:35:22+00:00 2026-06-18T23:35:22+00:00

I have a program that checks every second in the database for newly inserted

  • 0

I have a program that checks every second in the database for newly inserted row and if a new record is found, I have to clear my listModel and retrieve all data again from the database and re-display it in the list.

    itemListModel.clear();

    ArrayList resultArrayList = DBQueries.getAllSubmittedSaleTransaction();
    Iterator iterate = resultArrayList.iterator();

    int i = 0;
    while (iterate.hasNext()) {
        Hashtable data = (Hashtable) iterate.next();            
        itemListModel.add(i, data);

        this.itemList.addNotify();
        this.itemList.validate();
        this.itemList.repaint();

        i++;
    }
    this.validate();
    this.repaint();

but, the problem is, the repaint method sometimes work sometimes not.
Is there any smart way to accomplish this?

thanks in advance

  • 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-06-18T23:35:23+00:00Added an answer on June 18, 2026 at 11:35 pm

    You shouldn’t need to repaint the JList if you are updating the model, especially if your model calls fireContentsChanged(...) after the new data has been added. Be sure to only change the model on the Swing event thread.

    Consider that you

    • Do the database query in a SwingWorker.
    • Add a PropertyChangeListener to the SwingWorker
    • When the SwingWorker’s state property is changed to SwingWorker.StateValue.DONE, have the GUI get the new data from the SwingWorker and populate the ListModel on the EDT
    • And then have your ListModel fire its fireContentChanged(...) method.
    • The ListModel should extend AbstractListModel.
    • Note that if you’re able to use a DefaultListModel, you don’t even have to call the fireContent....() method since the DefaultListModel will do that for you.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that checks if a file is present every 3 seconds,
I have a simple program that checks webpages for strings, example: Private Sub Button1_Click(ByVal
On my program I have a function that checks for the current version of
I have been trying to write a powershell program that checks to see if
I have a C# program that works with an SQL Server database. The setup
I have an application that checks a resource on the internet for new mails.
We have a suite of programs that check for new versions at startup, and
I have program that requires Python 3, but I develop Django and it uses
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of

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.