Storing hidden values (IDs) in a listbox with values with Java Applications
<p>I don't know if this is possible. </p>

<pre><code>// Adding values to a listbox in Java
DefaultListModel&lt;String&gt; model = new DefaultListModel&lt;String&gt;();
model.addElement("One");
model.addElement("Two");
list1.setModel(model);
</code></pre>

<p>What I want is somehow to store a value in the listbox as follows:</p>

<pre><code>If user clicks on "One", ID=1 is retrieved.
If user clicks on "Two", ID=2 is retrieved.
</code></pre>

<p>I know how to retrieve the selected value, but I want to store a hidden ID.
This is easy to do with web based programming but not sure if it could be done with Java.</p>
