swingx
  1. swingx
  2. SWINGX-1544

JFormattedTextField.setFormatterFactory makes autocomplete work different

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.5
    • Fix Version/s: None
    • Component/s: Autocomplete
    • Labels:
      None
    • Environment:

      Java 7U13, Windows 8 Enterprise

      Description

      I am having a problem getting autocompletion to work correctly in JFormattetTextField.
      When I set the formatter factory the autocomplete seems to work as if it was strict
      Run the code and write F and press Delete and tabulate out of the field.
      I expected there to be a "F" in the field, but it contains "Foo"
      If i avoid setting the formatter factory, it works as I expected.
      Is this the intended behaviour?
      Is there some other way I should enable the autocomplete feature?

      AutoCompletionTest.java
      public class AutoCompletionTest {
      	public static void main(String[] args) {
      		JFrame f = new JFrame();
      		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      		DefaultFormatterFactory dff = new DefaultFormatterFactory(new DefaultFormatter());
      		JFormattedTextField tf = new JFormattedTextField();		
      		tf.setFormatterFactory(dff); // Disable this line and AutoCompleteDecorator works as I expect
      		AutoCompleteDecorator.decorate(tf, java.util.Arrays.asList("Foo", "Bar"), false);
      		JPanel p = new JPanel(new BorderLayout());
      		p.add(tf);
      		p.add(new JButton("Button"), BorderLayout.SOUTH);
      		f.add(p);
      		f.setSize(300, 100);
      		f.setLocationRelativeTo(null);
      		f.setVisible(true);
      	}
      }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Karl Schaefer
            Reporter:
            bskaarup
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: