Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

In this page you can find the example usage for java.util Vector add.

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:RemoveVector.java

public static void main(String args[]) {
    Vector v = new Vector();
    for (int i = 0, n = args.length; i < n; i++) {
        v.add(args[i]);
    }/*from   w w  w. j a  va2 s. c  o  m*/
    System.out.println(removeAll(v, args[0]));
    System.out.println(v);
}

From source file:Main.java

public static void main(String[] args) {
    Vector vec = new Vector(8);
    List sublist = new ArrayList(10);

    vec.add(4);
    vec.add(3);/*from   www.  j a  va 2 s . com*/
    vec.add(2);
    vec.add(1);
    vec.add(6);
    vec.add(7);
    vec.add(9);
    vec.add(5);

    sublist = vec.subList(2, 6);

    System.out.println(sublist);
}

From source file:TreeArraySample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JTreeSample");

    Vector oneVector = new NamedVector("One", args);
    Vector twoVector = new NamedVector("Two", new String[] { "Mercury", "Venus", "Mars" });
    Vector threeVector = new NamedVector("Three");
    threeVector.add(System.getProperties());
    threeVector.add(twoVector);//from  w  w  w . j av  a2  s .  c  o m
    Object rootNodes[] = { oneVector, twoVector, threeVector };
    Vector rootVector = new NamedVector("Root", rootNodes);
    JTree tree = new JTree(rootVector);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    //    frame.getContentPane().add(tree, BorderLayout.CENTER);
    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  .ja  v  a  2s .c  om*/
    Object rootNodes[] = { v1, v2 };
    Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes);
    JTree tree = new JTree(rootVector);
    frame.add(new JScrollPane(tree), BorderLayout.CENTER);
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:FindVector.java

public static void main(String args[]) {
    String data[] = { "Java", "Source", "and", "Support", "." };

    Vector v = new Vector();
    for (int i = 0, n = data.length; i < n; i++) {
        v.add(data[i]);
    }//from w ww  .j  a  v  a 2  s .  c o m
    System.out.println(v);
    System.out.println("Contains Java?: " + v.contains("Java"));
    System.out.println("Contains Java2s?: " + v.contains("Java2s"));
    System.out.println("Where's and?: " + v.indexOf("and"));
    System.out.println("Where's Source?: " + v.indexOf("Source"));
    System.out.println("Where's Java from end?: " + v.lastIndexOf("Java"));
}

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. ja v  a  2  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:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    System.out.println("The vector is empty: " + vec.isEmpty());

    vec.add(4);

    System.out.println("The vector is empty: " + vec.isEmpty());
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Vector<String> data = new Vector<String>();
    for (int i = 1; i < 100; i++) {
        data.add("Entry " + i);
    }//from   w  w w . j  a va2 s. c o  m
    JList<String> list = new JList<>(data);
    list.setVisibleRowCount(8);
    JScrollPane scrollPane = new JScrollPane(list);
    frame.add(scrollPane);
    frame.pack();
    frame.setVisible(true);
}

From source file:TreeNodeVector.java

public static void main(final String args[]) {
    UIManager.put("Tree.openIcon", new ImageIcon("yourFile.gif"));

    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  ww . j a v a2s.  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);

    frame.setSize(300, 300);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    Vector<Integer> vec = new Vector<Integer>(4);
    Integer[] anArray = new Integer[4];

    vec.add(4);
    vec.add(3);/* w  w  w .j a v  a  2  s. co  m*/
    vec.add(2);
    vec.add(1);

    // fill the array from the vector
    vec.toArray(anArray);

    for (int i = 0; i < anArray.length; i++) {
        System.out.println(anArray[i]);
    }
}