swingx
  1. swingx
  2. SWINGX-394

Unable to select autocomplete popup with arrow keys

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.0
    • Fix Version/s: 1.6.2
    • Component/s: Autocomplete
    • Labels:
      None
    • Environment:

      Operating System: Mac OS X
      Platform: Macintosh

    • Issuezilla Id:
      394

      Description

      When using the AutoCompleteDecorator on Mac OS X it is not possible to open the
      popup and change the selected value by using the up or down-Keys and then
      pressing the ENTER key.

      Demo code shows an undecorated editable JComboBox and in the second cell a
      decorated JComboBox using AutoCompleteDecorator. See that when you open the
      editor and then open the JComboBox popup you are not able to select a value by
      pressing up or down keys and the pressing enter key.

      BTW: Works on Windows 2000. On windows the selected value is directly inserted
      into the editor field which is not the case when working under OSX. After having
      pressed move the window and see the value in the editor field.

      Demo code follows:

      package alltests.de.dbap.util.xtable;

      import javax.swing.DefaultCellEditor;
      import javax.swing.JComboBox;
      import javax.swing.JFrame;
      import javax.swing.JScrollPane;
      import javax.swing.SwingUtilities;
      import javax.swing.table.DefaultTableModel;
      import javax.swing.table.TableCellEditor;

      import org.jdesktop.swingx.JXTable;
      import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
      import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;

      /**

      • Demonstrates AutoComplete error.
      • @author dhiller (creator)
      • @author $Author$ (last editor)
      • @version $Revision$
      • @since 27.09.2006 16:42:04
        */
        @SuppressWarnings( { "nls" , "serial" }

        )
        public class AutoCompleteDecoratorTest {

      private static final String[] VALUES = new String[]

      { "ONE" , "TWO" , "THREE" }

      ;

      /**

      • Starts program.
        *
      • @param args whatever
        */
        public static void main( String[] args ) {
        SwingUtilities.invokeLater( new Runnable() {
        public void run() {
        final JFrame frame = new JFrame();

      final JComboBox undecoratedBox = new JComboBox( VALUES );
      undecoratedBox.setEditable( true );
      final DefaultCellEditor undecoratedEditor = new DefaultCellEditor(
      undecoratedBox );

      final JComboBox decoratedBox = new JComboBox( VALUES );
      AutoCompleteDecorator.decorate( decoratedBox );
      final ComboBoxCellEditor decoratedEditor = new ComboBoxCellEditor(
      decoratedBox );

      final JXTable table = new JXTable() {
      @Override
      public TableCellEditor getCellEditor( int row , int column ) {
      if ( column == 0 )

      { return undecoratedEditor; }

      return decoratedEditor;
      }
      };
      table.setModel( new DefaultTableModel( new Object[][]{ new Object[]

      { "ONE" , "ONE" }

      } , new Object[]

      {"1" , "2"}

      ) );

      frame.getContentPane().add( new JScrollPane( table ) );
      frame.pack();
      frame.setVisible( true );
      }
      } );
      }

      }

      1. Fix394.diff
        9 kB
        Karl Schaefer
      2. Fix394.diff
        7 kB
        bierhance

        Activity

        Hide
        Karl Schaefer added a comment -

        Need someone with an OSX box to test this and report on its validity.

        Even if this is a bug, is it necessary for 1.0?

        Show
        Karl Schaefer added a comment - Need someone with an OSX box to test this and report on its validity. Even if this is a bug, is it necessary for 1.0?
        Hide
        Karl Schaefer added a comment -

        Pushing past 1.0, as with most autocomplete bugs. Patches will speed the
        progress up.

        Show
        Karl Schaefer added a comment - Pushing past 1.0, as with most autocomplete bugs. Patches will speed the progress up.
        Hide
        Karl Schaefer added a comment -

        Is this related to being in a table or not? Even on Windows the arrow keys
        have no effect on either combo box until the popup is displayed and then both
        work correctly.

        Show
        Karl Schaefer added a comment - Is this related to being in a table or not? Even on Windows the arrow keys have no effect on either combo box until the popup is displayed and then both work correctly.
        Hide
        bierhance added a comment -

        This only happens inside a table. It's not that arrow keys do not work. What does not work is the enter key.
        The selection gets lost when the enter key is pressed. This is somehow due to the key listener installed by
        the ComboBoxCellEditor.

        Show
        bierhance added a comment - This only happens inside a table. It's not that arrow keys do not work. What does not work is the enter key. The selection gets lost when the enter key is pressed. This is somehow due to the key listener installed by the ComboBoxCellEditor.
        Hide
        bierhance added a comment -

        Created an attachment (id=321)
        Proposed Fix

        Show
        bierhance added a comment - Created an attachment (id=321) Proposed Fix
        Hide
        Karl Schaefer added a comment -

        Created an attachment (id=322)
        Bierhance patch plus fix to AutoCompleteDocument

        Show
        Karl Schaefer added a comment - Created an attachment (id=322) Bierhance patch plus fix to AutoCompleteDocument
        Hide
        Karl Schaefer added a comment -

        Thomas,

        The original patch allows the editor to become wedged:
        Run user demo, tab to AutoComplete editor and type 'd', 'd', ENTER.

        I found the correct spot to initialize the adapter in the
        AutoCompleteDocument. This will prevent the error, whereby the decorator could
        become wedged only on the first use if an invalid value was entered into a
        strict box.

        If you'd like to ensure that my correction does not cause issues with the
        original patch that would be great.

        Karl

        Show
        Karl Schaefer added a comment - Thomas, The original patch allows the editor to become wedged: Run user demo, tab to AutoComplete editor and type 'd', 'd', ENTER. I found the correct spot to initialize the adapter in the AutoCompleteDocument. This will prevent the error, whereby the decorator could become wedged only on the first use if an invalid value was entered into a strict box. If you'd like to ensure that my correction does not cause issues with the original patch that would be great. Karl
        Hide
        bierhance added a comment -

        Fixed on head. I added also the fix suggested by Karl.

        Show
        bierhance added a comment - Fixed on head. I added also the fix suggested by Karl.

          People

          • Assignee:
            bierhance
            Reporter:
            dhiller_tmp
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: