void (@NotNull final DocumentEvent e) { // Order of document listeners invocation is not defined in Swing. In practice, custom listeners like this one are invoked // before internal JTextField listeners, so at this point the internal state of JTextField can be inconsistent. // That's the reason for using 'invokeLater' here. //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> preferredSizeChanged()); myTextFieldModified = true; }