Runnable () { JTextComponent component = getComponent(); return component == null ? null : () -> { component.setText(null); Object property = component.getClientProperty(ON_CLEAR); if (property instanceof ActionListener listener) { listener.actionPerformed(new ActionEvent(component, ActionEvent.ACTION_PERFORMED, "clear")); } }; }