0

I want to make a program in which when I write in the JTextArea, but when I write a word, it gives me a suggestion on how to complete it. I tried Swingx's AutoCompleteDecorator, but when I finished a word it wouldn't let me type anymore when I had it set to true in strict mode, and if I had it set to "false" it wouldn't give me any more suggestions afterwards. I used the following function:

AutoCompleteDecorator.decorate(textArea, keys, false);

shiosaku
  • 9
  • 5

1 Answers1

1

You can try the code as here.

Try this if you want dynamic fields using different key event listeners.

BigIO
  • 111
  • 8
  • I used the code exactly as it says and then like this: TAGSText.setFocusTraversalKeysEnabled(false); Autocomplete autoComplete = new Autocomplete(TAGSText, TAGSList); TAGSText.getDocument().addDocumentListener(autoComplete); TAGSText.getInputMap().put(KeyStroke.getKeyStroke("TAB"), COMMIT_ACTION); TAGSText.getActionMap().put(COMMIT_ACTION, autoComplete.new CommitAction()); But it´s not working – shiosaku Jul 02 '22 at 18:03
  • COMMIT_ACTION is a String "commit" – shiosaku Jul 02 '22 at 18:04
  • I already solved it, it turns out that the code only works if what is in the List starts with lowercase. I don't really understand why – shiosaku Jul 02 '22 at 18:51
  • @shiosaku that's good to hear you can upvote the answer if you like . – BigIO Jul 04 '22 at 03:22