Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:09:11+00:00 2026-06-09T20:09:11+00:00

In this thread , I’ve found a way to implement AutoComplete feature in a

  • 0

In this thread, I’ve found a way to implement AutoComplete feature in a JTextField (and JComboBox, but no issue with this).

When trying to implement this feature in a JTextField it throws some exceptions. The following code will demonstrate the issue. It’s so simple, much similar to the way I used with JComboBox, which is working fine.

Can someone help me to find a solution to this.

Here’s the code:
(Please note that i’m using swingx)

import javax.swing.JList;
import org.jdesktop.swingx.JXFrame;
import org.jdesktop.swingx.JXTextField;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

public class ErrorDemo {

    public static void main(String[] args) {
        JXFrame frame = new JXFrame("Error Demo");
        JXTextField field = new JXTextField();
        String[] users = {"aaa", "bbb", "ccc"};
        AutoCompleteDecorator.decorate(new JList(users), field);

        frame.getContentPane().add(field);
        frame.pack();
        frame.setLocationByPlatform(true);
        frame.setDefaultCloseOperation(JXFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

This is the error message i get :
(it’s a bit long 😀)

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.jdesktop.swingx.autocomplete.ListAdaptor.valueChanged(ListAdaptor.java:76)
    at javax.swing.JList.fireSelectionValueChanged(JList.java:1765)
    at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1779)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
    at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)
    at javax.swing.JList.setSelectedIndex(JList.java:2179)
    at javax.swing.JList.setSelectedValue(JList.java:2295)
    at org.jdesktop.swingx.autocomplete.ListAdaptor.setSelectedItem(ListAdaptor.java:98)
    at org.jdesktop.swingx.autocomplete.AutoCompleteDocument.setSelectedItem(AutoCompleteDocument.java:317)
    at org.jdesktop.swingx.autocomplete.AutoCompleteDocument.insertString(AutoCompleteDocument.java:265)
    at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1358)
    at javax.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:859)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2849)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2884)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2812)
    at java.awt.Component.processEvent(Component.java:5815)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
    at java.awt.Component.dispatchEventImpl(Component.java:4282)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:09:12+00:00Added an answer on June 9, 2026 at 8:09 pm

    There is no JList involved in your code. I think it should read something like this…

            org.jdesktop.swingx.autocomplete.AutoCompleteDecorator.decorate(field, Arrays.asList(users), false);
    

    If you want to bind a JList to a TextField (so that the text field will update the selection of the JList) you want decorate(JList list, JTextComponent textComponent, ObjectToStringConverter stringConverter) instead…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this thread I found some interesting moment, If class uses only as superclass
I looked at this thread but some of the concepts are above my current
This is discussed in this thread but it looks like it hasn't been documented
In this thread know how to make a eager load in rails , but
I'm sorry if this thread will be considered as subjective, but my question is
I found information from this thread and am starting to wonder if the information
This is the same issue as in this thread: Security ID Structure Invalid ,
I was recently reading this thread , on some of the worst PHP practices.
I found this thread about picking the closest/nearest value from an array based upon
I have seen this thread: WPF image resources and applied the information there. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.