List of usage examples for java.util Vector Vector
public Vector()
From source file:TreeNodeRemove.java
public static void main(String[] argv) { Vector<String> v = new Vector<String>(); v.add("a");// w ww . ja va 2 s. c o m v.add("b"); v.add("c"); JTree tree = new JTree(v); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); int startRow = 0; String prefix = "b"; TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Forward); MutableTreeNode node = (MutableTreeNode) path.getLastPathComponent(); model.removeNodeFromParent(node); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { String alg = "DSA"; KeyPairGenerator kg = KeyPairGenerator.getInstance(alg); KeyPair keyPair = kg.genKeyPair(); Vector v = new Vector(); v.add("This is a test!"); Signature sign = Signature.getInstance(alg); SignedObject so = new SignedObject(v, keyPair.getPrivate(), sign); System.out.println(so.verify(keyPair.getPublic(), sign)); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); arrayList.add("4"); arrayList.add("5"); Vector<String> v = new Vector<String>(); v.add("A");// w w w . j av a2 s .c o m v.add("B"); v.add("D"); v.add("E"); v.add("F"); v.add("G"); v.add("H"); System.out.println(v); Collections.copy(v, arrayList); System.out.println(v); }
From source file:SetViewportPosition.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> rowOne = new Vector<String>(); rowOne.addElement("Row1-Column1"); rowOne.addElement("Row1-Column2"); rowOne.addElement("Row1-Column3"); Vector<String> rowTwo = new Vector<String>(); rowTwo.addElement("Row2-Column1"); rowTwo.addElement("Row2-Column2"); rowTwo.addElement("Row2-Column3"); Vector<Vector> rowData = new Vector<Vector>(); rowData.addElement(rowOne);//from w w w. jav a2s . co m rowData.addElement(rowTwo); Vector<String> columnNames = new Vector<String>(); columnNames.addElement("Column One"); columnNames.addElement("Column Two"); columnNames.addElement("Column Three"); JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); scrollPane.getViewport().setViewPosition(new Point(0, 0)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { Vector<String> vec = new Vector<String>(); vec.add("a"); vec.add("b"); vec.add("c"); final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(vec); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox1 = new JComboBox<String>(model); comboBox1.setMaximumRowCount(5);/*from w w w .j a v a2 s .c o m*/ comboBox1.setEditable(true); frame.add(comboBox1, BorderLayout.NORTH); JList<String> jlist = new JList<String>(model); JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); JButton button = new JButton("Add"); frame.add(button, BorderLayout.SOUTH); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { model.addElement("a"); } }; button.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:CollectionTest.java
public static void main(String[] args) { nLoops = 10000;//from w ww. j ava2 s .com doTest(new Vector()); doTest(new ArrayList()); doTest(Collections.synchronizedList(new ArrayList())); nLoops = Integer.parseInt(args[0]); System.out.println("Starting synchronized vector test"); cleanGC(); Timestamp syncTS = new Timestamp(); doTest(new Vector()); syncTS.stop(); System.out.println("Synchronized vector took " + syncTS); System.out.println("Starting unsynchronized vector test"); cleanGC(); Timestamp unsyncTS = new Timestamp(); unsyncTS.stop(); System.out.println("Unsynchronized vector took " + unsyncTS); double d = ((double) (syncTS.elapsedTime() - unsyncTS.elapsedTime())) / nLoops; System.out.println("Unsynchronized operation saves " + d + " " + syncTS.units() + " per call"); System.out.println("Starting synchronized array list test"); cleanGC(); syncTS = new Timestamp(); doTest(Collections.synchronizedList(new ArrayList())); syncTS.stop(); System.out.println("Synchronized array list took " + syncTS); System.out.println("Starting unsynchronized array list test"); cleanGC(); unsyncTS = new Timestamp(); doTest(new ArrayList()); unsyncTS.stop(); System.out.println("Unsynchronized aray list took " + unsyncTS); d = ((double) (syncTS.elapsedTime() - unsyncTS.elapsedTime())) / nLoops; System.out.println("Unsynchronized operation saves " + d + " " + syncTS.units() + " per call"); }
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 . java 2 s . c o m*/ 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[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<Vector<String>> rowData = new Vector<Vector<String>>(); Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1")); for (int i = 0; i < 2000; i++) { rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i)))); }//w w w . j a v a2s . c o m JTable table = new JTable(rowData, columnName); JScrollPane scrollPane = new JScrollPane(table); JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setPreferredSize(new Dimension(0, 0)); f.add(scrollPane); f.pack(); f.setVisible(true); JViewport view = scrollPane.getViewport(); Component[] components = view.getComponents(); for (int i1 = 0; i1 < components.length; i1++) { if (components[i1] instanceof JTable) { System.out.println("got"); } } }
From source file:CollateApp.java
public static void main(String args[]) { if (args.length != 1) { System.out.println("Usage: java CollateApp file"); System.exit(0);/*w w w .j a v a 2 s. c o m*/ } Locale defaultLocale = Locale.getDefault(); RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(defaultLocale); Vector keyVector = new Vector(); try { BufferedReader in = new BufferedReader(new FileReader(args[0])); String line; while ((line = in.readLine()) != null) keyVector.addElement(collator.getCollationKey(line)); in.close(); } catch (Exception ex) { System.out.println(ex); System.exit(0); } CollationKey keys[] = new CollationKey[keyVector.size()]; for (int i = 0; i < keys.length; ++i) keys[i] = (CollationKey) keyVector.elementAt(i); }
From source file:CollateApp.java
public static void main(String args[]) { if (args.length != 1) { System.out.println("Usage: java CollateApp file"); System.exit(0);/*from www .j av a 2 s .c om*/ } Locale defaultLocale = Locale.getDefault(); RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(defaultLocale); Vector<Object> keyVector = new Vector<Object>(); try { BufferedReader in = new BufferedReader(new FileReader(args[0])); String line; while ((line = in.readLine()) != null) keyVector.addElement(collator.getCollationKey(line)); in.close(); } catch (Exception ex) { System.out.println(ex); System.exit(0); } CollationKey keys[] = new CollationKey[keyVector.size()]; for (int i = 0; i < keys.length; ++i) keys[i] = (CollationKey) keyVector.elementAt(i); }