List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:Main.java
/** * Code from http://stackoverflow.com/questions/1236231/managing-swing-ui-default-font-sizes-without-quaqua * @param fontSize//from ww w .j av a 2s .c o m */ public static void changeDefaultFontSize(int fontSize) { UIDefaults defaults = UIManager.getDefaults(); // UIDefaults defaults = UIManager.getLookAndFeelDefaults(); 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 source file:Main.java
static Hashtable hashtableClone(Hashtable ht) { if (ht == null) return null; Hashtable htresp = new Hashtable(); Enumeration e = ht.keys(); while (e.hasMoreElements()) { Object element = e.nextElement(); htresp.put(element, ht.get(element)); }/* w ww . ja v a 2 s. c om*/ return htresp; }
From source file:Main.java
/** * magnify the all fonts in swing./*w w w . ja v a2 s .c om*/ * * @param mag * magnify parameter <br/> mag > 1. : large <br/> mag < 1. : * small */ public static void magnifyAllFont(float mag) { List history = new LinkedList(); UIDefaults defaults = UIManager.getDefaults(); Enumeration it = defaults.keys(); while (it.hasMoreElements()) { Object key = it.nextElement(); Object a = defaults.get(key); if (a instanceof Font) { if (history.contains(a)) continue; Font font = (Font) a; font = font.deriveFont(font.getSize2D() * mag); defaults.put(key, font); history.add(font); } } }
From source file:Main.java
public static List toList(Enumeration e) { List list = new ArrayList(); while (e.hasMoreElements()) { list.add(e.nextElement()); }//from ww w . j a va 2s . c o m return list; }
From source file:com.asual.summer.onejar.OneJarServer.java
private static String getCurrentWarFile() throws IOException { JarFile jarFile = new JarFile(System.getProperty("java.class.path")); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.endsWith(".war")) { File war = new File(new File(System.getProperty("java.io.tmpdir")), "summer-onejar-" + System.currentTimeMillis() + ".war"); InputStream input = jarFile.getInputStream(new ZipEntry(name)); FileOutputStream output = new FileOutputStream(war); IOUtils.copy(input, output); IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); war.deleteOnExit();//from w w w . jav a 2 s.c o m return war.getAbsolutePath(); } } return null; }
From source file:Main.java
static Iterator getAlgNames() { Enumeration e = algorithms.keys(); List l = new ArrayList(); while (e.hasMoreElements()) { l.add(e.nextElement()); }/* w w w.j a v a2s . c om*/ return l.iterator(); }
From source file:Main.java
/** * Converts a Properties object into a Map. * /*from w w w . jav a 2 s.c o m*/ * @param properties * set of string key-value pairs * @returns map of key-value pairs (never null) */ public static Map<String, String> getMapFromProperties(Properties props) { Map<String, String> map = new HashMap<String, String>(); if (props != null) { Enumeration<Object> e = props.keys(); while (e.hasMoreElements()) { String s = (String) e.nextElement(); map.put(s, props.getProperty(s)); } } return map; }
From source file:Main.java
private static List<NameValuePair> buildNameValuePair(Hashtable<String, String> httpPost) { if (httpPost == null) return null; List<NameValuePair> nvps = new ArrayList<NameValuePair>(); Enumeration<String> keys = httpPost.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = (String) httpPost.get(key); BasicNameValuePair nv = new BasicNameValuePair(key, value); nvps.add(nv);/*from www .ja v a2 s. c o m*/ } return nvps; }
From source file:Main.java
public static AbstractButton getSelectedButton(ButtonGroup group) { Enumeration<AbstractButton> buttons = group.getElements(); while (buttons.hasMoreElements()) { AbstractButton b = buttons.nextElement(); if (b.isSelected()) { return b; }//from w w w . ja v a 2 s . c om } return null; }
From source file:Main.java
/** * Create a list from an enumeration/* w w w . ja v a 2 s.com*/ * * @param e the enumeration * @return the list */ public static List list(Enumeration e) { ArrayList result = new ArrayList(); while (e.hasMoreElements()) result.add(e.nextElement()); return result; }