private void changeDocument( final @CheckForNull Document oldDoc, final @CheckForNull Document newDoc, final boolean update) { if (newDoc == oldDoc) return; if (null != oldDoc) oldDoc.removeDocumentListener(listener); if (null != newDoc) { if (update) { String txt; try { txt = newDoc.getText(0, newDoc.getLength()); } catch (BadLocationException e) { txt = null; } update(txt); } newDoc.addDocumentListener(listener); } }
private void documentUpdated() { if (lock()) return; try { final JComboBox<E> cb = getComboBox(); final ComboBoxEditor cbe = cb.getEditor(); final JTextComponent tc = (JTextComponent) cbe.getEditorComponent(); assert cb.isShowing() || !tc.isFocusOwner(); if (!tc.isFocusOwner() /* || !cb.isShowing() */) return; //cb.setPopupVisible(update(tc.getText())); // doesn't work: adjusts popup size! cb.setPopupVisible(false); if (update(tc.getText())) cb.setPopupVisible(true); } finally { unlock(); } }