Here you can find the source of setSliderLabels(JSlider slider, int[] values, String[] labels)
Parameter | Description |
---|---|
slider | a parameter |
values | a parameter |
labels | a parameter |
public static void setSliderLabels(JSlider slider, int[] values, String[] labels)
//package com.java2s; //License from project: Open Source License import java.util.Hashtable; import javax.swing.JLabel; import javax.swing.JSlider; public class Main { /**/*from w w w.j av a2 s. c o m*/ * Set the labels of a slider. * @param slider * @param values * @param labels */ public static void setSliderLabels(JSlider slider, int[] values, String[] labels) { assert (slider != null && values != null && labels != null); assert (values.length == labels.length); Hashtable labelTable = new Hashtable(); for (int i = 0; i < values.length; i++) { assert (values[i] >= slider.getMinimum()); assert (values[i] <= slider.getMaximum()); JLabel label = new JLabel(labels[i]); labelTable.put(new Integer(values[i]), label); } slider.setLabelTable(labelTable); } }