JBLabel () { JBLabel duplicatesCount = new JBLabel(); if (myDuplicatesCountSupplier != null) { duplicatesCount.setText(JavaRefactoringBundle.message("refactoring.extract.method.dialog.duplicates.pending")); ProgressManager.getInstance().run( new Task.Backgroundable(myProject, JavaRefactoringBundle.message("refactoring.extract.method.dialog.duplicates.progress")) { @Override public void run(@NotNull ProgressIndicator indicator) { int count = ReadAction.compute(myDuplicatesCountSupplier::get); ApplicationManager.getApplication().invokeLater( () -> { if (count != 0) { showCount(UIUtil.getBalloonInformationIcon(), " " + JavaRefactoringBundle.message("refactoring.extract.method.dialog.duplicates.count", count), JBUI.Borders.empty(18, 0)); } else { showCount(null, "", null); } }, ModalityState.any()); } private void showCount(Icon icon, @NlsContexts.Label String message, Border border) { duplicatesCount.setIcon(icon); duplicatesCount.setText(message); duplicatesCount.setBorder(border); } }); } return duplicatesCount; }