void () { final JTextField textField = myHomeComponent.getTextField(); if (textField.getText().isEmpty() && !mySdk.getSdkType().isLocalSdk(mySdk)) { return; } ApplicationManager.getApplication().executeOnPooledThread(() -> { var homeDir = Path.of(textField.getText()); var homeMustBeDirectory = ((SdkType)mySdk.getSdkType()).getHomeChooserDescriptor().isChooseFolders(); var isValid = homeMustBeDirectory ? Files.isDirectory(homeDir) : Files.isRegularFile(homeDir); ApplicationManager.getApplication().invokeLater( () -> textField.setForeground(isValid ? UIUtil.getFieldForegroundColor() : PathEditor.INVALID_COLOR), ModalityState.stateForComponent(myHomeComponent) ); }); }