Remove « JList « Java Swing Q&A





1. How do I remove multiple labels from a panel?    stackoverflow.com

In reference to this: How do I display something I enter in a JOptionPane on the JFrame? I've made a JList which also outputs what I've inputted, and it displays on ...

2. Remove from JList    coderanch.com

3. Remove JList    coderanch.com

the best way to do this is to create a new model, and set it as the list's model. no need to remove/add the JList here's a simple demo import javax.swing.*; import java.awt.*; import java.awt.event.*; class Testing extends JFrame { String[] cities = {"London","Madrid","New York","Rome","Sydney","Tokyo"}; DefaultListModel listModel = new DefaultListModel(); JList list = new JList(listModel); public Testing() { setLocation(400,300); setDefaultCloseOperation(EXIT_ON_CLOSE); for(int ...