List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);/*from w w w . j ava 2 s .c o m*/ Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); frame.add(new JScrollPane(tree), BorderLayout.CENTER); tree.expandRow(1); tree.scrollRowToVisible(2); tree.revalidate(); frame.setSize(300, 300); frame.setVisible(true); }
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);/*from w w w . j a va 2s . co m*/ Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); UIManager.put("Tree.line", Color.GREEN); tree.putClientProperty("JTree.lineStyle", "Horizontal"); frame.add(new JScrollPane(tree), BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }
From source file:FindVector2.java
public static void main(String args[]) { Vector v = new Vector(); for (int i = 0, n = members.length; i < n; i++) { v.add(members[i]); }//from ww w . j a va2s.c o m System.out.println(v); System.out.println("Contains Society?: " + v.contains("Society")); System.out.println("Contains Waldo?: " + v.contains("Waldo")); System.out.println("Where's Waldo?: " + v.indexOf("Waldo")); System.out.println("Where's Thoreau?: " + v.indexOf("Thoreau")); System.out.println("Where's Thoreau from end?: " + v.lastIndexOf("Thoreau")); int index = 0; int length = v.size(); while ((index < length) && (index >= 0)) { index = v.indexOf("Thoreau", index); if (index != -1) { System.out.println(v.get(index)); index++; } } }
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);/*from ww w . j a v a 2s .c o m*/ Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); Color backgroundSelection = renderer.getBackgroundSelectionColor(); renderer.setBackgroundSelectionColor(renderer.getBackgroundNonSelectionColor()); renderer.setBackgroundNonSelectionColor(backgroundSelection); Color textSelection = renderer.getTextSelectionColor(); renderer.setTextSelectionColor(renderer.getTextNonSelectionColor()); renderer.setTextNonSelectionColor(textSelection); frame.add(new JScrollPane(tree), BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(); for (int i = 0, n = members.length; i < n; i++) { v.add(members[i]); }/* w w w .j ava 2 s . c o m*/ System.out.println(v); System.out.println("Contains A?: " + v.contains("A")); System.out.println("Where's A?: " + v.indexOf("A")); System.out.println("Where's B from end?: " + v.lastIndexOf("B")); int index = 0; int length = v.size(); while ((index < length) && (index >= 0)) { index = v.indexOf("C", index); if (index != -1) { System.out.println(v.get(index)); index++; } } }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); Vector<Integer> vecclone = new Vector<Integer>(4); vec.add(4); vec.add(3);/*ww w . j av a 2s . co m*/ vec.add(2); vec.add(1); System.out.println(vec); // let us clone the vector vec vecclone = (Vector) vec.clone(); System.out.println(vecclone); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); Vector<Integer> vecretain = new Vector<Integer>(4); vec.add(1); vec.add(2);// w w w . j a v a 2s .c o m vec.add(3); vec.add(4); vec.add(5); vec.add(6); vec.add(7); // this elements will be retained vecretain.add(5); vecretain.add(3); vecretain.add(2); vec.retainAll(vecretain); for (Integer number : vec) { System.out.println("Number = " + number); } }
From source file:Main.java
public static void main(String[] args) throws Exception { File archivo = new File("c:/Java_Dev/run.bat"); FileReader fr = new FileReader(archivo); BufferedReader br = new BufferedReader(fr); Vector<String> lines = new Vector<String>(); String line;/*from w w w. ja v a 2 s . c om*/ while ((line = br.readLine()) != null) { lines.add(line); } JOptionPane.showMessageDialog(null, new JScrollPane(new JList(lines))); fr.close(); }
From source file:Main.java
public static void main(String[] arguments) { String[] codes = { "alpha", "lambda", "gamma", "delta", "zeta" }; Vector list = new Vector(); for (int i = 0; i < codes.length; i++) { if (!list.contains(codes[i])) { list.add(codes[i]); }//from w w w .j ava2 s .co m } for (Iterator ite = list.iterator(); ite.hasNext();) { String output = (String) ite.next(); System.out.println(output); } }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> firstvec = new Vector<Integer>(4); Vector<Integer> secondvec = new Vector<Integer>(4); // use add() method to add elements in the secondvec vector secondvec.add(5); secondvec.add(6);/*w ww .j a v a2 s. co m*/ secondvec.add(7); secondvec.add(8); // use add() method to add elements in the firstvec vector firstvec.add(1); firstvec.add(2); firstvec.add(3); firstvec.add(4); /** use addAll() method to add elements of the 2nd vector at 1st element position of the first vector */ firstvec.addAll(1, secondvec); System.out.println(firstvec); }