Example usage for java.util Enumeration hasMoreElements

List of usage examples for java.util Enumeration hasMoreElements

Introduction

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

Prototype

boolean hasMoreElements();

Source Link

Document

Tests if this enumeration contains more elements.

Usage

From source file:Main.java

/** Fully expands the given JTree from the specified node. */
public static void expandTree(final JTree tree, final DefaultMutableTreeNode node) {
    if (node.isLeaf())
        return;//from w  w w  . ja  v  a 2 s .c  om
    tree.expandPath(new TreePath(node.getPath()));
    final Enumeration e = node.children();
    while (e.hasMoreElements()) {
        expandTree(tree, (DefaultMutableTreeNode) e.nextElement());
    }
}

From source file:Main.java

public static List toList(Enumeration e) {
    List list = new ArrayList();
    while (e.hasMoreElements()) {
        list.add(e.nextElement());/*w ww .  j av a  2 s .  co  m*/
    }
    return list;
}

From source file:PropertiesDemo.java

static void iterateKeys(Locale currentLocale) {

    ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);

    Enumeration bundleKeys = labels.getKeys();

    while (bundleKeys.hasMoreElements()) {
        String key = (String) bundleKeys.nextElement();
        String value = labels.getString(key);
        System.out.println("key = " + key + ", " + "value = " + value);
    }//  w  w  w .  j  a va  2  s.c o m

}

From source file:Main.java

static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) {
    if (ht1 == null && ht2 == null)
        return null;

    Hashtable htresp = new Hashtable();

    if (ht1 != null) {
        Enumeration e = ht1.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht1.get(element));
        }//w  w  w  . ja  va2s  .c  o m
    }
    if (ht2 != null) {
        Enumeration e = ht2.keys();
        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht2.get(element));
        }
    }
    return htresp;
}

From source file:Main.java

public static String replaceSystemProps(String xml) {
    Properties properties = System.getProperties();
    Enumeration e = properties.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String s = "${" + key + "}";
        if (xml.contains(s)) {
            xml = xml.replace(s, properties.getProperty(key));
        }/*from   w ww.j  av  a 2 s. c  o m*/

    }
    return xml;
}

From source file:Main.java

public static void setUIFont(FontUIResource f) {
    ///*from w  w  w  .  j a v a  2 s .  c om*/
    // sets the default FONT for all Swing components.
    // ex.
    // setUIFont (new javax.swing.plaf.FontUIResource
    // ("Serif",Font.ITALIC,12));
    //
    Enumeration<Object> keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource)
            UIManager.put(key, f);
    }
}

From source file:EnumerationIterator1.java

public static Iterator iterator(final Enumeration e) {
    return new Iterator() {
        public boolean hasNext() {
            return e.hasMoreElements();
        }/*from   w w w.j  ava 2  s.c o m*/

        public Object next() {
            return e.nextElement();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}

From source file:Main.java

public static void setUIFont(Font f) {
    ////w  w w.j  a  v  a 2s  .co m
    // sets the default font for all Swing components.
    // ex. 
    //  setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
    //
    FontUIResource fur = new FontUIResource(f);
    java.util.Enumeration keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put(key, fur);
    }
}

From source file:Main.java

public static int getButtonGroupSelectIndex(ButtonGroup bg) {
    if (bg.getButtonCount() <= 0) {
        return -1;
    }/*from w  w w. j  ava2s  . c om*/
    Enumeration<AbstractButton> bEnum = bg.getElements();
    for (int i = 0; bEnum.hasMoreElements(); i++) {
        AbstractButton temp = bEnum.nextElement();
        if (temp.isSelected()) {
            return i;
        }

    }
    return -1;
}

From source file:Main.java

static Iterator getAlgNames() {
    Enumeration e = algorithms.keys();
    List l = new ArrayList();

    while (e.hasMoreElements()) {
        l.add(e.nextElement());/*from  ww w  .  j  a v  a 2  s .  c o  m*/
    }

    return l.iterator();
}