您应该在单独的线程中更新列表,否则最终将阻塞事件分发线程。
请尝试以下操作:
final DefaultListModel model = new DefaultListModel();final JList list = new JList(model);//another thread to update the modelfinal Thread updater = new Thread() { @Override public void run() { for (int i = 0; i < 10; i++) { model.addElement(i); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } } }};updater.start();


