Retrieving selected AutoComplete Object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieving selected AutoComplete Object

njrzdevil
I have a setback in using GlazedLists within my program and would love
your assistance in solving this (probably simple) problem.

I'm using an autocomplete text box:
AutoCompleteSupport support = AutoCompleteSupport.install(
                        comboBox, dataCenter.createCommands());
               
BasicEventList<Command> is what is used, and Command
contains both a String and unique ID #.


Essentially, right now I have the code working such that when the
user presses enter, I look at the text inside the text box after an
ActionEvent
via:

((JTextField) comboBox.getEditor().getEditorComponent()).getText();
       
The problem with this is that I could have two Commands, both with the
same name (which is the toString) but different unique ID's.

Visually, I could overcome this via color coding, but functionally, I
cannot determine the difference as the Strings are the same.

Essentially what I'm asking is, Is there any way that I can see which
Command (Object) was selected on ActionEvent? As opposed to just the
String?
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving selected AutoComplete Object

James Lemieux
comboBox.getSelectedItem() should be the method you're looking for.


On Sun, May 19, 2013 at 12:21 PM, <[hidden email]> wrote:
I have a setback in using GlazedLists within my program and would love
your assistance in solving this (probably simple) problem.

I'm using an autocomplete text box:
AutoCompleteSupport support = AutoCompleteSupport.install(
                        comboBox, dataCenter.createCommands());

BasicEventList<Command> is what is used, and Command
contains both a String and unique ID #.


Essentially, right now I have the code working such that when the
user presses enter, I look at the text inside the text box after an
ActionEvent
via:

((JTextField) comboBox.getEditor().getEditorComponent()).getText();

The problem with this is that I could have two Commands, both with the
same name (which is the toString) but different unique ID's.

Visually, I could overcome this via color coding, but functionally, I
cannot determine the difference as the Strings are the same.

Essentially what I'm asking is, Is there any way that I can see which
Command (Object) was selected on ActionEvent? As opposed to just the
String?