I am currently trying to setup a custom label for a JSlider in Java.
I looked up into the Java API and found this method: public void setLabelTable(Dictionary labels)
Unfortunately it turns out the Dictionary
class and it's subclass Hashtable
is obsolete.
According to the answer of this question: Using Java Dictionary...use a Hashtable?
The Hashtable
class has been 'replaced' with HashMap
.
So I tried to send a HashMap
instead of a Hashtable
, which I highly doubted it would work.
As expected, the compiler gave me this error:
incompatible types: HashMap<Integer, JLabel> cannot be converted to Dictionary
I can choose to use the Dictionary
and the Hashtable
class and compile with Xlint:Deprecated
and it will give me the result that I want.
But I don't want to use something that's been obsolete for a while.
What should I use instead of setLabelTable(Dictionary labels)
?
Or is there no other way than using setLabelTable(Dictionary labels)
?
I want to produce this GUI without using a deprecated or obsolete API.