This fixes an issue with new elements beeing added to a JList. The list layout hasn't been updated in such a case, thus making the new element invisible until the updateLayoutState() is triggered by another change to the list.
2006-01-30 Roman Kennke <[EMAIL PROTECTED]> * javax/swing/plaf/basic/BasicListUI.java (ListDataHandler.contentsChanged): Update the updateLayoutStateNeeded flag. (ListDataHandler.intervalAdded): Update the updateLayoutStateNeeded flag. (ListDataHandler.intervalRemoved): Update the updateLayoutStateNeeded flag. (PropertyChangeHandler.propertyChange): Correctly update the listeners on new list model. (maybeUpdateLayoutState): Don't consider the validation state of the list. /Roman
Index: javax/swing/plaf/basic/BasicListUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v retrieving revision 1.53 diff -u -r1.53 BasicListUI.java --- javax/swing/plaf/basic/BasicListUI.java 30 Jan 2006 08:35:50 -0000 1.53 +++ javax/swing/plaf/basic/BasicListUI.java 30 Jan 2006 13:44:40 -0000 @@ -135,6 +135,7 @@ */ public void contentsChanged(ListDataEvent e) { + updateLayoutStateNeeded |= modelChanged; list.revalidate(); } @@ -145,6 +146,7 @@ */ public void intervalAdded(ListDataEvent e) { + updateLayoutStateNeeded |= modelChanged; list.revalidate(); } @@ -155,6 +157,7 @@ */ public void intervalRemoved(ListDataEvent e) { + updateLayoutStateNeeded |= modelChanged; list.revalidate(); } } @@ -541,17 +544,21 @@ */ public void propertyChange(PropertyChangeEvent e) { - if (e.getSource() == BasicListUI.this.list) + if (e.getPropertyName().equals("model")) { if (e.getOldValue() != null && e.getOldValue() instanceof ListModel) - ((ListModel) e.getOldValue()).removeListDataListener(BasicListUI.this.listDataListener); - + { + ListModel oldModel = (ListModel) e.getOldValue(); + oldModel.removeListDataListener(listDataListener); + } if (e.getNewValue() != null && e.getNewValue() instanceof ListModel) - ((ListModel) e.getNewValue()).addListDataListener(BasicListUI.this.listDataListener); + { + ListModel newModel = (ListModel) e.getNewValue(); + newModel.addListDataListener(BasicListUI.this.listDataListener); + } + + updateLayoutStateNeeded |= modelChanged; } - // Update the updateLayoutStateNeeded flag. - if (e.getPropertyName().equals("model")) - updateLayoutStateNeeded |= modelChanged; else if (e.getPropertyName().equals("selectionModel")) updateLayoutStateNeeded |= selectionModelChanged; else if (e.getPropertyName().equals("font")) @@ -899,7 +906,7 @@ */ protected void maybeUpdateLayoutState() { - if (updateLayoutStateNeeded != 0 || !list.isValid()) + if (updateLayoutStateNeeded != 0) { updateLayoutState(); updateLayoutStateNeeded = 0;