Java Code Examples for java.util.Dictionary#elements()
The following examples show how to use
java.util.Dictionary#elements() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: darklaf File: DarkSliderUI.java License: MIT License | 6 votes |
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(); }
Example 2
Source Project: java-swing-tips File: MainPanel.java License: MIT License | 6 votes |
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; }
Example 3
Source Project: jdk1.8-source-analysis File: BasicSliderUI.java License: Apache License 2.0 | 5 votes |
/** * 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; }
Example 4
Source Project: dragonwell8_jdk File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 5
Source Project: TencentKona-8 File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 6
Source Project: jdk8u60 File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 7
Source Project: JDKSourceCode1.8 File: BasicSliderUI.java License: MIT License | 5 votes |
/** * 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; }
Example 8
Source Project: openjdk-jdk8u File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 9
Source Project: openjdk-jdk8u-backup File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 10
Source Project: Bytecoder File: BasicSliderUI.java License: Apache License 2.0 | 5 votes |
/** * 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; }
Example 11
Source Project: openjdk-jdk9 File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 12
Source Project: jdk8u-jdk File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 13
Source Project: Java8CN File: BasicSliderUI.java License: Apache License 2.0 | 5 votes |
/** * 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; }
Example 14
Source Project: hottub File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 15
Source Project: openjdk-8-source File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 16
Source Project: openjdk-8 File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 17
Source Project: jdk8u_jdk File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 18
Source Project: knopflerfish.org File: RequestImpl.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@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; }
Example 19
Source Project: jdk8u-jdk File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 20
Source Project: jdk8u-dev-jdk File: BasicSliderUI.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }