Example usage for java.util Enumeration nextElement

List of usage examples for java.util Enumeration nextElement

Introduction

In this page you can find the example usage for java.util Enumeration nextElement.

Prototype

E nextElement();

Source Link

Document

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Usage

From source file:Main.java

public static <T> void addAll(Collection<T> c, Enumeration<T> enumeration) {
    while (enumeration.hasMoreElements()) {
        c.add(enumeration.nextElement());
    }/*  ww w .j a  v a  2 s. c o  m*/
}

From source file:Main.java

public static final List<String> getListFromBundle(ResourceBundle rb, String prefix) {
    String name = null;/*from  ww  w  . ja v a2s .com*/
    List<String> ret = new LinkedList<String>();
    Enumeration<String> names = rb.getKeys();
    while (names.hasMoreElements()) {
        name = names.nextElement();
        if (name != null && name.startsWith(prefix) && isInteger(name.substring(name.length() - 1))) {
            ret.add(rb.getString(name));
        }
    }
    Collections.sort(ret);
    return ret;
}

From source file:Main.java

public static Collection enumToCollection(Enumeration e) {
    ArrayList result = new ArrayList();
    while (e.hasMoreElements()) {
        result.add(e.nextElement());
    }//  w  ww .j  a v  a  2 s .  c  om
    return result;
}

From source file:Main.java

public static void setLookAndFeel(int fontSize) throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    UIDefaults defaults = UIManager.getDefaults();
    Enumeration<Object> keys = defaults.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();

        if ((key instanceof String) && (((String) key).endsWith(".font"))) {
            FontUIResource font = (FontUIResource) UIManager.get(key);
            defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
        }//from ww w .jav a2  s.  com
    }
}

From source file:Main.java

public static Properties convertResourceBundleToProperties(ResourceBundle resource) {
    Properties properties = new Properties();

    Enumeration<String> keys = resource.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        properties.put(key, resource.getString(key));
        //System.out.println("key: '" + key + "' value: '" + properties.get(key) + "'");
    }/*from w  ww .j a va2  s. c  o  m*/

    return properties;
}

From source file:Main.java

public static void setButtonGroupEnabled(ButtonGroup buttonGroup, boolean enabled) {
    Enumeration<AbstractButton> buttonEnum = buttonGroup.getElements();
    while (buttonEnum.hasMoreElements()) {
        buttonEnum.nextElement().setEnabled(enabled);
    }//from ww w  . java  2  s  . com
}

From source file:Main.java

/**
 * Returns string keys in a hashtable as array of string
 *
 * @param ht/* w w w.j av  a  2s  .  com*/
 *            , Hashtable
 * @return , string array with hash keys string
 */
public static synchronized String[] hashtableKeysToArray(Hashtable ht) {
    Vector v = new Vector();
    String[] sa = null;
    int count = 0;

    Enumeration e = ht.keys();
    while (e.hasMoreElements()) {
        String s = (String) e.nextElement();
        v.addElement(s);
        count++;
    }

    sa = new String[count];
    v.copyInto(sa);
    return sa;

}

From source file:Main.java

/**
 * For testing only - prevent the tests to exit until all thread finished
 *//*  w w  w .  j a  va  2s  . c  om*/
public static void waitForBackgroundThreads() {
    Enumeration e = threads.elements();
    while (e.hasMoreElements()) {
        Thread thread = (Thread) e.nextElement();
        if (thread.isAlive()) {
            try {
                thread.join();
            } catch (InterruptedException ignore) {
                ignore.printStackTrace();
            }
        }
    }
}

From source file:Main.java

public static void printUIDefaults() {
    UIDefaults uiDefaults = UIManager.getDefaults();
    Enumeration<Object> e = uiDefaults.keys();
    while (e.hasMoreElements()) {
        Object key = e.nextElement();
        Object val = uiDefaults.get(key);
        System.out.println("[" + key.toString() + "]:[" + (null != val ? val.toString() : "(null)") + "]");
    }/*from w  w w.j a va2  s .co  m*/
}

From source file:Main.java

public static DefaultMutableTreeNode buscarNodeByNombre(JTree jtree, String nodeStr) {
    DefaultMutableTreeNode node = null;
    TreeNode root = (TreeNode) jtree.getModel().getRoot();
    Enumeration<?> e = root.children();
    while (e.hasMoreElements()) {
        node = (DefaultMutableTreeNode) e.nextElement();
        if ((node.getUserObject().toString()).contains(nodeStr)) {
            return node;
        }/*from  w  ww  .  j  a  v  a 2s.c  om*/
    }
    return null;
}