java.util.Dictionary#elements ( )源码实例Demo

下面列出了java.util.Dictionary#elements ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: darklaf   文件: DarkSliderUI.java
public Dimension getPreferredHorizontalSize() {
    Dimension dim = super.getPreferredHorizontalSize();
    Rectangle rect = new Rectangle(0, 0, 0, 0);
    rect.setSize(dim);
    adjustRect(rect, true);
    Dictionary<?, ?> dict = slider.getLabelTable();
    if (dict != null && !dict.isEmpty()) {
        int totalLabelWidth = 0;
        Enumeration<?> labels = dict.elements();
        while (labels.hasMoreElements()) {
            Object obj = labels.nextElement();
            if (obj instanceof Component) {
                totalLabelWidth += ((Component) obj).getPreferredSize().width;
            }
        }
        totalLabelWidth += getThumbWidth();
        rect.width = Math.max(rect.width, totalLabelWidth);
    }
    return rect.getSize();
}
 
源代码2 项目: java-swing-tips   文件: MainPanel.java
private static JSlider makeSlider(String title) {
  JSlider slider = new JSlider(0, 100, 40);
  slider.setBorder(BorderFactory.createTitledBorder(title));
  slider.setMajorTickSpacing(10);
  slider.setPaintTicks(true);
  slider.setPaintLabels(true);
  Dictionary<?, ?> dictionary = slider.getLabelTable();
  if (Objects.nonNull(dictionary)) {
    Enumeration<?> elements = dictionary.elements();
    while (elements.hasMoreElements()) {
      JLabel label = (JLabel) elements.nextElement();
      int v = Integer.parseInt(label.getText());
      if (v > MAXI || v < MINI) {
        label.setForeground(Color.RED);
      }
    }
  }
  slider.getModel().addChangeListener(e -> {
    BoundedRangeModel m = (BoundedRangeModel) e.getSource();
    m.setValue(Math.max(MINI, Math.min(m.getValue(), MAXI)));
  });
  return slider;
}
 
源代码3 项目: jdk1.8-source-analysis   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码4 项目: dragonwell8_jdk   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码5 项目: TencentKona-8   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码6 项目: jdk8u60   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码7 项目: JDKSourceCode1.8   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码8 项目: openjdk-jdk8u   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码10 项目: Bytecoder   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        @SuppressWarnings("rawtypes")
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration<?> elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码11 项目: openjdk-jdk9   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        @SuppressWarnings("rawtypes")
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration<?> elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码12 项目: jdk8u-jdk   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码13 项目: Java8CN   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码14 项目: hottub   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码15 项目: openjdk-8-source   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码16 项目: openjdk-8   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码17 项目: jdk8u_jdk   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码18 项目: knopflerfish.org   文件: RequestImpl.java
@Override
public Cookie[] getCookies()
{
  Dictionary<String, Cloneable> d;
  if (cookies == null && !(d = base.getCookies()).isEmpty()) {
    cookies = new Cookie[d.size()];
    final Enumeration<Cloneable> e = d.elements();
    for (int i = 0; i < cookies.length; i++) {
      cookies[i] = (Cookie) e.nextElement();
    }
  }

  return cookies;
}
 
源代码19 项目: jdk8u-jdk   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}
 
源代码20 项目: jdk8u-dev-jdk   文件: BasicSliderUI.java
/**
 * Returns true if all the labels from the label table have the same
 * baseline.
 *
 * @return true if all the labels from the label table have the
 *         same baseline
 * @since 1.6
 */
protected boolean labelsHaveSameBaselines() {
    if (!checkedLabelBaselines) {
        checkedLabelBaselines = true;
        Dictionary dictionary = slider.getLabelTable();
        if (dictionary != null) {
            sameLabelBaselines = true;
            Enumeration elements = dictionary.elements();
            int baseline = -1;
            while (elements.hasMoreElements()) {
                JComponent label = (JComponent) elements.nextElement();
                Dimension pref = label.getPreferredSize();
                int labelBaseline = label.getBaseline(pref.width,
                                                      pref.height);
                if (labelBaseline >= 0) {
                    if (baseline == -1) {
                        baseline = labelBaseline;
                    }
                    else if (baseline != labelBaseline) {
                        sameLabelBaselines = false;
                        break;
                    }
                }
                else {
                    sameLabelBaselines = false;
                    break;
                }
            }
        }
        else {
            sameLabelBaselines = false;
        }
    }
    return sameLabelBaselines;
}