Hashtable is "old", so you should use HashMap instead.
You can get a collection of all values ββin a Hashtable by calling values ββ(). OOPS - I read your question incorrectly, change it to keySet (). If you are happy with displaying them in a JList using their toString () method (for example, these are strings), just add them all to the JList. Unfortunately, JList designers, at least in J6, donβt take Collections (my favorite motive is how many Collections were around ???), so you have to work a little there.
One warning. Hashtable and HashMap organize their entries in a rather unpredictable way. Thus, the order of values ββin a JList will almost certainly not be the order you want. Consider using LinkedHashMap or TreeMap to maintain a more reasonable order.
source share