private TreeMap<Integer, String> getSortedTree() { Dictionary dictionary = jSlider.getLabelTable(); TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>(); for (Enumeration indices = dictionary.keys(); indices.hasMoreElements(); ) { Integer index = (Integer) indices.nextElement(); JComponent component = (JComponent) dictionary.get(index); treeMap.put(index, ComponentUtils.getDisplayedName(component)); } return treeMap; }
private int getIndexForLabel(String label) { Dictionary dictionary = jSlider.getLabelTable(); for (Enumeration indices = dictionary.keys(); indices.hasMoreElements(); ) { Integer index = (Integer) indices.nextElement(); JComponent component = (JComponent) dictionary.get(index); if (label.equals(ComponentUtils.getDisplayedName(component))) { return index; } } return -1; }
private String getCurrentLabel() { int value = jSlider.getValue(); Dictionary dictionary = jSlider.getLabelTable(); for (Enumeration indices = dictionary.keys(); indices.hasMoreElements(); ) { Integer index = (Integer) indices.nextElement(); JComponent component = (JComponent) dictionary.get(index); if (Utils.equals(index, value)) { return ComponentUtils.getDisplayedName(component); } } return null; }