This sligthly changes the ordering in which the BasicTextUI installs its
bits on text components. I once had a problem here with some component
having a null font while building up its View, resulting in an NPE.
2006-02-16 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicTextUI.java
(installUI): Moved installation of PropertyChangeListener
to installListeners(). Call modelChanged() after everything is
is installed.
(installListeners): Install PropertyChangeListener here.
(uninstallUI): Moved uninstallation of PropertyChangeListener
to uninstallListeners.
(uninstallListeners): Uninstall PropertyChangeListener here.
/Roman
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.67
diff -u -r1.67 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java 9 Feb 2006 13:56:28 -0000 1.67
+++ javax/swing/plaf/basic/BasicTextUI.java 16 Feb 2006 14:31:15 -0000
@@ -516,19 +516,19 @@
c.setOpaque(true);
textComponent = (JTextComponent) c;
-
Document doc = textComponent.getDocument();
if (doc == null)
{
- doc = getEditorKit(textComponent).createDefaultDocument();
- textComponent.setDocument(doc);
+ doc = getEditorKit(textComponent).createDefaultDocument();
+ textComponent.setDocument(doc);
}
- textComponent.addPropertyChangeListener(updateHandler);
- modelChanged();
-
installDefaults();
installListeners();
installKeyboardActions();
+
+ // We need to trigger this so that the view hierarchy gets initialized.
+ modelChanged();
+
}
/**
@@ -584,6 +584,7 @@
protected void installListeners()
{
textComponent.addFocusListener(focuslistener);
+ textComponent.addPropertyChangeListener(updateHandler);
installDocumentListeners();
}
@@ -728,8 +729,6 @@
super.uninstallUI(component);
rootView.setView(null);
- textComponent.removePropertyChangeListener(updateHandler);
-
uninstallDefaults();
uninstallListeners();
uninstallKeyboardActions();
@@ -752,6 +751,7 @@
*/
protected void uninstallListeners()
{
+ textComponent.removePropertyChangeListener(updateHandler);
textComponent.removeFocusListener(focuslistener);
textComponent.getDocument().removeDocumentListener(documentHandler);
}