RFR: 5032471: JFormattedTextField does not use editformatter on initial focus with setText() [v2]

Alexey Ivanov aivanov at openjdk.org
Fri Jul 28 19:49:50 UTC 2023


On Wed, 26 Jul 2023 03:26:02 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> > The bug report mentions using `setDocument()` to change the value of the formatted text field. Also, it's possible to call `getDocument().setText()`, which may still have the original bug.
> 
> Fixed setDocument but I couldn't find Document.setText that can be called...

Sorry about it, `Document` uses `insertString` method. Perhaps, we shouldn't care about it, if you modify the text using the `Document` interface directly, you could lose the invariants that `JFormattedTextField` provides. The [javadoc](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/JFormattedTextField.html) also mentions, that you should not install your own `DocumentFilter` and `NavigationFilter`.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14993#issuecomment-1656235954



More information about the client-libs-dev mailing list