Hey, This patch fixes two minor bugs in JTabbedPane.java.
The first is that when a new tab is added/inserted, if there is no tab currently selected, then this one automatically is. The problem was that this change was not being notified to the ChangeListeners, when it should be. The second bug was that in the setModel method, a new ChangeListener was being created if the current one was not null. This obviously shouldn't be the case. A new ChangeListener should only be created if there does not exist one. Because of these changes, tab switching now works properly in the Java2DDemo. Can someone kindly approve/comment on this patch. Cheers, Tania 2006-09-20 Tania Bento <[EMAIL PROTECTED]> * javax/swing/JTabbedPane.java: (insertTab): Notify ChangeListeners if the tab inserted is selected. (setModel): A ChangeListener should be created only if there does not currently exist one.
Index: javax/swing/JTabbedPane.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v retrieving revision 1.44 diff -u -r1.44 JTabbedPane.java --- javax/swing/JTabbedPane.java 13 Aug 2006 01:15:26 -0000 1.44 +++ javax/swing/JTabbedPane.java 20 Sep 2006 21:15:32 -0000 @@ -887,7 +887,7 @@ if (model != null) { - if (changeListener != null) + if (changeListener == null) changeListener = createChangeListener(); model.addChangeListener(changeListener); } @@ -1054,7 +1054,10 @@ } if (getSelectedIndex() == -1) - setSelectedIndex(0); + { + setSelectedIndex(0); + fireStateChanged(); + } revalidate(); repaint();