/** * This factory method creates and returns a {@link AutoCompleteCellEditor} * which adapts an autocompleting {@link JComboBox} for use as a Table * Cell Editor. The values within the <code>source</code> are used as * autocompletion terms within the {@link ComboBoxModel}. * * <p>If the appearance or function of the autocompleting {@link JComboBox} * is to be customized, it can be retrieved using * {@link AutoCompleteCellEditor#getComponent()}. * * @param source the source of data for the JComboBox within the table cell editor * @return a {@link AutoCompleteCellEditor} which contains an autocompleting * combobox whose model contents are determined by the given <code>source</code> */ public static <E> AutoCompleteCellEditor<E> createTableCellEditor(EventList<E> source) { // build a special JComboBox used only in Table Cell Editors final JComboBox comboBox = new TableCellComboBox(); comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // install autocompletion support on the special JComboBox final AutoCompleteSupport<E> autoCompleteSupport = AutoCompleteSupport.install(comboBox, source); autoCompleteSupport.setSelectsTextOnFocusGain(false); // create an AutoCompleteCellEditor using the AutoCompleteSupport object final AutoCompleteCellEditor<E> cellEditor = new AutoCompleteCellEditor<E>(autoCompleteSupport); cellEditor.setClickCountToStart(2); return cellEditor; }
/** * This factory method creates and returns a {@link AutoCompleteCellEditor} * which adapts an autocompleting {@link JComboBox} for use as a Table * Cell Editor. The values within the <code>source</code> are used as * autocompletion terms within the {@link ComboBoxModel}. * * <p>If the appearance or function of the autocompleting {@link JComboBox} * is to be customized, it can be retrieved using * {@link AutoCompleteCellEditor#getComponent()}. * * @param source the source of data for the JComboBox within the table cell editor * @return a {@link AutoCompleteCellEditor} which contains an autocompleting * combobox whose model contents are determined by the given <code>source</code> */ public static <E> AutoCompleteCellEditor<E> createTableCellEditor(EventList<E> source) { // build a special JComboBox used only in Table Cell Editors final JComboBox comboBox = new TableCellComboBox(); comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // install autocompletion support on the special JComboBox final AutoCompleteSupport<E> autoCompleteSupport = AutoCompleteSupport.install(comboBox, source); autoCompleteSupport.setSelectsTextOnFocusGain(false); // create an AutoCompleteCellEditor using the AutoCompleteSupport object final AutoCompleteCellEditor<E> cellEditor = new AutoCompleteCellEditor<E>(autoCompleteSupport); cellEditor.setClickCountToStart(2); return cellEditor; }
/** * This factory method creates and returns a {@link AutoCompleteCellEditor} * which adapts an autocompleting {@link JComboBox} for use as a Table * Cell Editor. The values within the <code>source</code> are used as * autocompletion terms within the {@link ComboBoxModel}. * * <p>If the appearance or function of the autocompleting {@link JComboBox} * is to be customized, it can be retrieved using * {@link AutoCompleteCellEditor#getComponent()}. * * @param source the source of data for the JComboBox within the table cell editor * @return a {@link AutoCompleteCellEditor} which contains an autocompleting * combobox whose model contents are determined by the given <code>source</code> */ public static <E> AutoCompleteCellEditor<E> createTableCellEditor(EventList<E> source) { // build a special JComboBox used only in Table Cell Editors final JComboBox comboBox = new TableCellComboBox(); comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // install autocompletion support on the special JComboBox final AutoCompleteSupport<E> autoCompleteSupport = AutoCompleteSupport.install(comboBox, source); autoCompleteSupport.setSelectsTextOnFocusGain(false); // create an AutoCompleteCellEditor using the AutoCompleteSupport object final AutoCompleteCellEditor<E> cellEditor = new AutoCompleteCellEditor<E>(autoCompleteSupport); cellEditor.setClickCountToStart(2); return cellEditor; }