FormattedTextField: On Linux, fixed IllegalArgumentException: Invalid location if JFormattedTextField.setDocument() is invoked in a focus gained listener on that formatted text field. (issue #698)

This commit is contained in:
Karl Tauber
2023-07-17 15:45:03 +02:00
parent c790778a46
commit 19afbe99d9
2 changed files with 9 additions and 2 deletions

View File

@@ -30,6 +30,9 @@ FlatLaf Change Log
- Native Windows libraries: Fixed crash when running in Java 8 and newer Java
version is installed in `PATH` environment variable and using class
`SystemInfo` before AWT initialization. (issue #673)
- FormattedTextField: On Linux, fixed `IllegalArgumentException: Invalid
location` if `JFormattedTextField.setDocument()` is invoked in a focus gained
listener on that formatted text field. (issue #698)
## 3.1.1

View File

@@ -256,10 +256,14 @@ public class FlatCaret
// select all
if( c instanceof JFormattedTextField ) {
EventQueue.invokeLater( () -> {
if( getComponent() == null )
// Warning: do not use variables from outside of this runnable
// because they may be out-of-date when this runnable is executed
JTextComponent c2 = getComponent();
if( c2 == null )
return; // was deinstalled
select( 0, doc.getLength() );
select( 0, c2.getDocument().getLength() );
} );
} else {
select( 0, doc.getLength() );