
Signature
Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.
Sleep - thing used by ineffective people
as a substitute for coffee
Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------
"Konrad Den Ende" <tmp1@viltersten.com> wrote in news:cphjog$6g7$1
@news.gu.se:
> I'm trying to set labels on a JSlider and of what i see
> i have to make an instance of Dictionary class. Since
[quoted text clipped - 3 lines]
> Should i extend Dictionary class anyway or is there a
> better way to put my own labels on the ticks?
This looks like an oversight in the definition of JSlider. Dictionary
has been replaced by the Map interface.
Still, you just need to supply the data in a form that meets the
Dictionary contract.
If you look at Dictionary in the javadocs you'll see that the only
"direct known subclass" is Hashtable.
Thus, you want to supply a set of values in a Hashtable (which by
definition meets the contract for a Dictionary).
The online tutorial gives this example:
//Create the slider
JSlider framesPerSecond = new JSlider(JSlider.VERTICAL,
FPS_MIN, FPS_MAX, FPS_INIT);
framesPerSecond.addChangeListener(this);
framesPerSecond.setMajorTickSpacing(10);
framesPerSecond.setPaintTicks(true);
//Create the label table
Hashtable labelTable = new Hashtable();
labelTable.put( new Integer( 0 ), new JLabel("Stop") );
labelTable.put( new Integer( FPS_MAX/10 ), new JLabel("Slow") );
labelTable.put( new Integer( FPS_MAX ), new JLabel("Fast") );
framesPerSecond.setLabelTable( labelTable );
framesPerSecond.setPaintLabels(true);
Chas Douglass
Konrad Den Ende - 12 Dec 2004 18:04 GMT
>> Should i extend Dictionary class anyway or is there a
>> better way to put my own labels on the ticks?
[quoted text clipped - 4 lines]
> Thus, you want to supply a set of values in a Hashtable (which by
> definition meets the contract for a Dictionary).
Aha! I knew i missed something. Thanks for the help

Signature
Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.
Sleep - thing used by ineffective people
as a substitute for coffee
Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------