void (@NotNull JComboBox comboBox, @NotNull List<String> variants) { Object prototypeDisplayValue = comboBox.getPrototypeDisplayValue(); String prototypeDisplayValueStr = null; if (prototypeDisplayValue instanceof String) { prototypeDisplayValueStr = (String)prototypeDisplayValue; } else if (prototypeDisplayValue != null) { return; } String longest = StringUtil.notNullize(prototypeDisplayValueStr); boolean updated = false; for (@NlsSafe String s : variants) { if (longest.length() < s.length()) { longest = s; updated = true; } } if (updated) { comboBox.setPrototypeDisplayValue(longest); } }