private void highlightItem(int pos) { if (pos == -1) return; String text = textField.getText(); String[] parts = text.split(","); int start = 0; for (int i = 0; i < pos; i++) start += parts[i].length() + 1; if (pos >= parts.length) return; int end = start + parts[pos].length(); textField.highlight(start, end); int width = textField.getFontMetrics(textField.getFont()).stringWidth(text.substring(0, start)); textField.getHorizontalVisibility().setValue(width); } // highlightItem