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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:55:17+00:00 2026-05-31T07:55:17+00:00

I have a JList and I use a DefaultListModel to store the list entries.

  • 0

I have a JList and I use a DefaultListModel to store the list entries.
I have a button on that panel. When the button is clicked, I add new entry to DefaultListModel .

button actionPerformed:

My problem is, after I did the operation on my DefaultListModel, the content of JList doesn’t change, I’m wondering that do I need to call a sort of refresh method on JList after I make changes on the ListModel?

public void actionPerformed(ActionEvent e) {
        ModifyXMLFile.create(FileList.listModel);
        FileList.fileList1.revalidate();
    }

JList Class:

public class FileList {
public static DefaultListModel listModel;
public static WebList fileList1 = null;
public static Component getGui(File[] all) {
    listModel = new DefaultListModel();
    for(File file:all){
      listModel.addElement(file);
    }
    final WebList fileList = new WebList(listModel);
    fileList1=fileList;
    fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileList.setCellRenderer(new FileRenderer(!vertical));

    fileList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {


    });     
}
  • 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-31T07:55:18+00:00Added an answer on May 31, 2026 at 7:55 am

    1) remove code line panel.updateUI(); this code line is about Look And Feels

    2) Swing is single threaded and updates to the Swing GUI must be done on EDT, otherwise contents or changes to the GUI are not visible or contents isn’t refreshed or freeze

    3) you have look at SwingWorker for loading JList's Item on the background task, then output from SwingWorker to the GUI will be done on EDT

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

Sidebar

Related Questions

I have a JList which uses a DefaultListModel. I then add values to the
I have a JList which i want to use to display a list a
I am trying to add JList component to panel but the list look weird
I have a JList that holds a bunch of strings . I would like
I have a JList inside a Scrollpane. If you click on the list and
Currently, I have a JList listen to list selection listener. private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt)
I'm making a swing based application where I have a JList that periodically get's
I have a JList nested inside of a JScrollPane. When I add items to
I have a JList with a DefaultListModel . How I can make an item
I have Java class with JList and ListSelectionListener: final JList myList = new JList();

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.