1. Can not clear the JList Java stackoverflow.comI am using NETBEANS 7 . I have on JList in my project. Here is my code
|
2. Clearing a jList coderanch.com |
3. Clearing a JList coderanch.comlistModel.clear() works OK to remoave all elements list.clearSelection() is the other one you need try this import java.awt.*; import java.awt.event.*; import javax.swing.*; class Testing extends JFrame implements ActionListener { DefaultListModel listModel = new DefaultListModel(); JList list = new JList(listModel); JScrollPane sp = new JScrollPane(list); JButton btn1 = new JButton("Add"); JButton btn2 = new JButton("Clear Selection"); JButton btn3 = new JButton("Clear List"); ... |
4. Clearing a JList coderanch.com |
5. To clear the JList forums.oracle.comprivate final JList getAvailableList(final Class pClientClass) { JList wAnswer = (JList) getAvailableLists().get(pClientClass); if (wAnswer == null) { wAnswer = new JList(getAvailableListModel(pClientClass)); wAnswer.setFixedCellWidth(150); // Add double-click listener to the list PjxMouseListener wMouseListener = new PjxMouseAdapter() { public void pjxMouseClicked(MouseEvent pEvent) { if (pEvent.getClickCount() == 2) { handleAddRequested(pClientClass); } } }; wAnswer.addMouseListener(wMouseListener); getAvailableLists().put(pClientClass, wAnswer); } return wAnswer; } |
6. help clearing a jlist forums.oracle.comI'm using netbeans 5.5. I have a couple of Jlists on a gui and a button click event that populates the Jlists. I am trying to make it so that everytime the button is clicked, it clears the Jlist's first before populating them. Currently when the button is clicked it just appends the new population items to the previous lists. The ... |