src/share/classes/javax/swing/JSlider.java

Print this page

        

*** 136,147 **** /** * {@code Dictionary} of what labels to draw at which values */ ! private Dictionary<Integer, ? extends JComponent> labelTable; ! /** * The changeListener (no suffix) is the listener we add to the * slider's model. This listener is initialized to the * {@code ChangeListener} returned from {@code createChangeListener}, --- 136,150 ---- /** * {@code Dictionary} of what labels to draw at which values */ ! @SuppressWarnings("rawtypes") ! private Dictionary labelTable; ! // For better source compatibility, the labelTable field and ! // associated getter and setter methods are being left as raw ! // types. /** * The changeListener (no suffix) is the listener we add to the * slider's model. This listener is initialized to the * {@code ChangeListener} returned from {@code createChangeListener},
*** 771,784 **** if (!isShowing()) { return false; } // Check that there is a label with such image ! Enumeration<? extends JComponent> elements = labelTable.elements(); while (elements.hasMoreElements()) { ! JComponent component = elements.nextElement(); if (component instanceof JLabel) { JLabel label = (JLabel) component; if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) || --- 774,787 ---- if (!isShowing()) { return false; } // Check that there is a label with such image ! Enumeration<?> elements = labelTable.elements(); while (elements.hasMoreElements()) { ! Component component = (Component) elements.nextElement(); if (component instanceof JLabel) { JLabel label = (JLabel) component; if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img) ||
*** 795,805 **** * Returns the dictionary of what labels to draw at which values. * * @return the <code>Dictionary</code> containing labels and * where to draw them */ ! public Dictionary<Integer, ? extends JComponent> getLabelTable() { /* if ( labelTable == null && getMajorTickSpacing() > 0 ) { setLabelTable( createStandardLabels( getMajorTickSpacing() ) ); } */ --- 798,809 ---- * Returns the dictionary of what labels to draw at which values. * * @return the <code>Dictionary</code> containing labels and * where to draw them */ ! @SuppressWarnings("rawtypes") ! public Dictionary getLabelTable() { /* if ( labelTable == null && getMajorTickSpacing() > 0 ) { setLabelTable( createStandardLabels( getMajorTickSpacing() ) ); } */
*** 828,839 **** * hidden: true * bound: true * attribute: visualUpdate true * description: Specifies what labels will be drawn for any given value. */ ! public void setLabelTable( Dictionary<Integer, ? extends JComponent> labels ) { ! Dictionary<Integer, ? extends JComponent> oldTable = labelTable; labelTable = labels; updateLabelUIs(); firePropertyChange("labelTable", oldTable, labelTable ); if (labels != oldTable) { revalidate(); --- 832,844 ---- * hidden: true * bound: true * attribute: visualUpdate true * description: Specifies what labels will be drawn for any given value. */ ! @SuppressWarnings("rawtypes") ! public void setLabelTable( Dictionary labels ) { ! Dictionary oldTable = labelTable; labelTable = labels; updateLabelUIs(); firePropertyChange("labelTable", oldTable, labelTable ); if (labels != oldTable) { revalidate();
*** 850,878 **** * * @see #setLabelTable * @see JComponent#updateUI */ protected void updateLabelUIs() { ! Dictionary<Integer, ? extends JComponent> labelTable = getLabelTable(); if (labelTable == null) { return; } ! Enumeration<Integer> labels = labelTable.keys(); while ( labels.hasMoreElements() ) { ! JComponent component = labelTable.get(labels.nextElement()); component.updateUI(); component.setSize(component.getPreferredSize()); } } private void updateLabelSizes() { ! Dictionary<Integer, ? extends JComponent> labelTable = getLabelTable(); if (labelTable != null) { ! Enumeration<? extends JComponent> labels = labelTable.elements(); while (labels.hasMoreElements()) { ! JComponent component = labels.nextElement(); component.setSize(component.getPreferredSize()); } } } --- 855,885 ---- * * @see #setLabelTable * @see JComponent#updateUI */ protected void updateLabelUIs() { ! @SuppressWarnings("rawtypes") ! Dictionary labelTable = getLabelTable(); if (labelTable == null) { return; } ! Enumeration<?> labels = labelTable.keys(); while ( labels.hasMoreElements() ) { ! JComponent component = (JComponent) labelTable.get(labels.nextElement()); component.updateUI(); component.setSize(component.getPreferredSize()); } } private void updateLabelSizes() { ! @SuppressWarnings("rawtypes") ! Dictionary labelTable = getLabelTable(); if (labelTable != null) { ! Enumeration<?> labels = labelTable.elements(); while (labels.hasMoreElements()) { ! JComponent component = (JComponent) labels.nextElement(); component.setSize(component.getPreferredSize()); } } }
*** 980,996 **** } if ( e.getPropertyName().equals( "minimum" ) || e.getPropertyName().equals( "maximum" ) ) { ! Enumeration<Integer> keys = getLabelTable().keys(); Hashtable<Integer, JComponent> hashtable = new Hashtable<>(); // Save the labels that were added by the developer while ( keys.hasMoreElements() ) { ! Integer key = keys.nextElement(); ! JComponent value = labelTable.get(key); if ( !(value instanceof LabelUIResource) ) { hashtable.put( key, value ); } } --- 987,1003 ---- } if ( e.getPropertyName().equals( "minimum" ) || e.getPropertyName().equals( "maximum" ) ) { ! Enumeration<?> keys = getLabelTable().keys(); Hashtable<Integer, JComponent> hashtable = new Hashtable<>(); // Save the labels that were added by the developer while ( keys.hasMoreElements() ) { ! Integer key = (Integer) keys.nextElement(); ! JComponent value = (JComponent) labelTable.get(key); if ( !(value instanceof LabelUIResource) ) { hashtable.put( key, value ); } }
*** 998,1008 **** createLabels(); // Add the saved labels keys = hashtable.keys(); while ( keys.hasMoreElements() ) { ! Integer key = keys.nextElement(); put( key, hashtable.get( key ) ); } ((JSlider)e.getSource()).setLabelTable( this ); } --- 1005,1015 ---- createLabels(); // Add the saved labels keys = hashtable.keys(); while ( keys.hasMoreElements() ) { ! Integer key = (Integer) keys.nextElement(); put( key, hashtable.get( key ) ); } ((JSlider)e.getSource()).setLabelTable( this ); }
*** 1015,1025 **** } } SmartHashtable table = new SmartHashtable( increment, start ); ! Dictionary<Integer, ? extends JComponent> labelTable = getLabelTable(); if (labelTable != null && (labelTable instanceof PropertyChangeListener)) { removePropertyChangeListener((PropertyChangeListener) labelTable); } --- 1022,1033 ---- } } SmartHashtable table = new SmartHashtable( increment, start ); ! @SuppressWarnings("rawtypes") ! Dictionary labelTable = getLabelTable(); if (labelTable != null && (labelTable instanceof PropertyChangeListener)) { removePropertyChangeListener((PropertyChangeListener) labelTable); }