Search code examples
javaswingjslider

Using Java Dictionary...use a Hashtable?


I'm a bit surprised no one has asked about this specific case, cause it's kind of a weird inconsistency in the java standard libraries:

I'm using swing JSliders with custom labels; the only library call available to assign labels is: setLabelTable(Dictionary labels)

But Dictionary is an abstract class, and its only known subclass in the standard lib is Hashtable, which the api & various IDE's complain about because it's "obsolete."

The obvious thing to do is just use the Hashtable, but I'm wondering two things:

  1. Is there a better way to approach this?
  2. If Hashtable is the only usable class for this (in my opinion) reasonably important library call, on what basis is it "obsolete"?

Thanks!


Solution

  • The reason Hashtable is obsolete is because it was was replaced with Hashmap.

    However, for the purposes of assigning labels to a setLabelTable, the "deficiencies" of Hashtable are not a problem.