Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327581

Add default setDocumentFilter method to javax.swing.text.Document interface

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      Way back in Java 1.4, the javax.swing.text.AbstractDocument class got a useful new method: setDocumentFilter(DocumentFilter filter). At the time, it couldn't be added to the Document interface, so anyone who wants to use it must first cast a text component's Document to AbstractDocument or maybe PlainDocument to call the method. This was a bit inconvenient. But now, with default methods, it would be useful to add it to the interface. The default implementation doesn't need to do anything. It could throw an UnsupportedOperationException or other unchecked exception without causing any problem, because all implementations of Document currently extend AbstractDocument, which provides the implementation for all concrete Document classes. So the exception would never get thrown. Even in the very unusual case where a user has written their own implementation of Document, they would either have added their own setDocumentFilter() method, or they wouldn't have implemented it, in which case they're not calling the method and won't see the exception. So this would be a very low risk change that would be very helpful.


            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: