List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:Main.java
public static void main(String[] args) throws IOException { Vector theStreams = new Vector(); for (int i = 0; i < args.length; i++) { FileInputStream fin = new FileInputStream(args[i]); theStreams.addElement(fin); }/* ww w .ja va 2 s. c o m*/ InputStream in = new SequenceInputStream(theStreams.elements()); for (int i = in.read(); i != -1; i = in.read()) { System.out.write(i); } }
From source file:MainClass.java
public static void main(String args[]) { // initial size is 3, increment is 2 Vector<Integer> v = new Vector<Integer>(3, 2); System.out.println("Initial size: " + v.size()); System.out.println("Initial capacity: " + v.capacity()); v.addElement(1); v.addElement(2);// w w w. ja v a2 s .c om System.out.println("First element: " + v.firstElement()); System.out.println("Last element: " + v.lastElement()); if (v.contains(3)) System.out.println("Vector contains 3."); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(4);/*w w w . ja va2 s .c o m*/ vec.add(3); vec.add(2); vec.add(1); System.out.println(vec); // add new element vec.addElement(12); System.out.println(vec); }
From source file:Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*//from ww w .j a va 2 s . co m * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this is a global * property and cannot be scoped. It might not be suitable for your * application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:EmbedJTableSWTNoFlicker.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*//w w w . ja v a 2s. c o m * Set a Windows specific AWT property that prevents heavyweight components * from erasing their background. Note that this is a global property and * cannot be scoped. It might not be suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 154"); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*//from w w w . j a v a 2s . c om * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this * is a global property and cannot be scoped. It might not be * suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { @Override public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector<Vector<String>> rows = new Vector<>(); for (int i = 0; i < nrows; i++) { Vector<String> row = new Vector<>(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector<String> columns = new Vector<>(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
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 w w w . ja v a 2s. 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 w w w . j a v a2 s. c o m*/ } 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); }
From source file:CreateVector.java
public static void main(String args[]) { {//w w w . ja v a 2s . c o m Vector v = new Vector(0); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); } { Vector v = new Vector(); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); } }
From source file:Main.java
public static void main(String[] args) { Vector<Double> doubleVector = new Vector<Double>(); Vector<Integer> integerVector = new Vector<Integer>(); Vector<Boolean> booleanVector = new Vector<Boolean>(); Vector<Icon> iconVector = new Vector<Icon>(); Icon icon1 = ((UIManager.getIcon("OptionPane.errorIcon"))); Icon icon2 = (UIManager.getIcon("OptionPane.informationIcon")); Icon icon3 = (UIManager.getIcon("OptionPane.warningIcon")); Icon icon4 = (UIManager.getIcon("OptionPane.questionIcon")); doubleVector.addElement(1.001); doubleVector.addElement(10.00);/*from w w w. ja v a 2s.com*/ doubleVector.addElement(0.95); doubleVector.addElement(4.2); JComboBox comboBoxDouble = new JComboBox(doubleVector); integerVector.addElement(1); integerVector.addElement(2); integerVector.addElement(3); integerVector.addElement(4); JComboBox comboBoxInteger = new JComboBox(integerVector); booleanVector.add(Boolean.TRUE); booleanVector.add(Boolean.FALSE); JComboBox comboBoxBoolean = new JComboBox(booleanVector); iconVector.addElement(icon1); iconVector.addElement(icon2); iconVector.addElement(icon3); iconVector.addElement(icon4); JComboBox comboBoxIcon = new JComboBox(iconVector); JFrame frame = new JFrame(); frame.setLayout(new GridLayout(2, 2, 5, 5)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(comboBoxDouble); frame.add(comboBoxInteger); frame.add(comboBoxBoolean); frame.add(comboBoxIcon); frame.pack(); frame.setVisible(true); }