List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:com.yahoo.messenger.data.notification.json.BuddyInfoContactList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); BuddyInfoContact c = new BuddyInfoContact(); c.unserializeJSON(o);/*from w ww . ja va 2s.c o m*/ v.addElement(c); } buddyInfoContacts = new BuddyInfoContact[v.size()]; v.copyInto(buddyInfoContacts); }
From source file:org.apache.tomcat.util.IntrospectionUtils.java
/** * Add all the jar files in a dir to the classpath, represented as a Vector * of URLs./*from w w w . j a v a 2 s .c o m*/ */ public static void addToClassPath(Vector cpV, String dir) { try { String cpComp[] = getFilesByExt(dir, ".jar"); if (cpComp != null) { int jarCount = cpComp.length; for (int i = 0; i < jarCount; i++) { URL url = getURL(dir, cpComp[i]); if (url != null) cpV.addElement(url); } } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);//ww w.j av a2 s .c o m GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; // Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; // Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); // It's easier to see the focus change // if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; // Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; // Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); // The setRequestFocusEnabled method prevents a // component from being clickable, but it can still // get the focus through the keyboard - this ensures // user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.yahoo.messenger.data.json.UserList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); User c = new User(); c.unserializeJSON(o.getJSONObject("user")); v.addElement(c); }//from w w w . j av a 2 s . c o m users = new User[v.size()]; v.copyInto(users); }
From source file:com.yahoo.messenger.data.json.GroupList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Group c = new Group(); c.unserializeJSON(o.getJSONObject("group")); v.addElement(c); }/*w w w . ja v a 2 s . c om*/ groups = new Group[v.size()]; v.copyInto(groups); }
From source file:DatabaseBrowser.java
protected void populateSchemaBox() { try {/*w w w . j a v a2 s. co m*/ DatabaseMetaData dmd = connection.getMetaData(); ResultSet rset = dmd.getSchemas(); Vector values = new Vector(); while (rset.next()) { values.addElement(rset.getString(1)); } rset.close(); schemaBox.setModel(new DefaultComboBoxModel(values)); schemaBox.setEnabled(values.size() > 0); } catch (Exception e) { schemaBox.setEnabled(false); } }
From source file:DatabaseBrowser.java
protected void populateCatalogBox() { try {/* w ww. j ava 2 s .c o m*/ DatabaseMetaData dmd = connection.getMetaData(); ResultSet rset = dmd.getCatalogs(); Vector values = new Vector(); while (rset.next()) { values.addElement(rset.getString(1)); } rset.close(); catalogBox.setModel(new DefaultComboBoxModel(values)); catalogBox.setSelectedItem(connection.getCatalog()); catalogBox.setEnabled(values.size() > 0); } catch (Exception e) { catalogBox.setEnabled(false); } }
From source file:com.yahoo.messenger.data.json.ContactList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Contact c = new Contact(); c.unserializeJSON(o.getJSONObject("contact")); v.addElement(c); }/*from ww w.j ava2s. c o m*/ contacts = new Contact[v.size()]; v.copyInto(contacts); }
From source file:DatabaseBrowser.java
protected void populateTableBox() { try {/*from w ww . j ava2 s. c o m*/ String[] types = { "TABLE" }; String catalog = connection.getCatalog(); String schema = (String) (schemaBox.getSelectedItem()); DatabaseMetaData dmd = connection.getMetaData(); ResultSet rset = dmd.getTables(catalog, schema, null, types); Vector values = new Vector(); while (rset.next()) { values.addElement(rset.getString(3)); } rset.close(); tableBox.setModel(new DefaultComboBoxModel(values)); tableBox.setEnabled(values.size() > 0); } catch (Exception e) { tableBox.setEnabled(false); } }
From source file:com.yahoo.messenger.data.json.PreferenceList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Preference c = new Preference(); c.unserializeJSON(o.getJSONObject("preference")); v.addElement(c); }/* w w w .j a v a2s. c om*/ preferences = new Preference[v.size()]; v.copyInto(preferences); }