1 /*
2 * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * This class loosely implements the <code>java.util.Vector</code>
36 * API, in that it implements the 1.1.x version of
37 * <code>java.util.Vector</code>, has no collection class support,
38 * and notifies the <code>ListDataListener</code>s when changes occur.
39 * Presently it delegates to a <code>Vector</code>,
40 * in a future release it will be a real Collection implementation.
41 * <p>
42 * <strong>Warning:</strong>
43 * Serialized objects of this class will not be compatible with
44 * future Swing releases. The current serialization support is
45 * appropriate for short term storage or RMI between applications running
46 * the same version of Swing. As of 1.4, support for long term storage
47 * of all JavaBeans™
48 * has been added to the <code>java.beans</code> package.
49 * Please see {@link java.beans.XMLEncoder}.
50 *
51 * @param <E> the type of the elements of this model
52 *
53 * @author Hans Muller
54 */
55 public class DefaultListModel<E> extends AbstractListModel<E>
56 {
57 private Vector<E> delegate = new Vector<E>();
58
59 /**
60 * Returns the number of components in this list.
61 * <p>
62 * This method is identical to <code>size</code>, which implements the
63 * <code>List</code> interface defined in the 1.2 Collections framework.
64 * This method exists in conjunction with <code>setSize</code> so that
65 * <code>size</code> is identifiable as a JavaBean property.
66 *
67 * @return the number of components in this list
68 * @see #size()
69 */
70 public int getSize() {
71 return delegate.size();
72 }
73
74 /**
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
35 * This class loosely implements the <code>java.util.Vector</code>
36 * API, in that it implements the 1.1.x version of
37 * <code>java.util.Vector</code>, has no collection class support,
38 * and notifies the <code>ListDataListener</code>s when changes occur.
39 * Presently it delegates to a <code>Vector</code>,
40 * in a future release it will be a real Collection implementation.
41 * <p>
42 * <strong>Warning:</strong>
43 * Serialized objects of this class will not be compatible with
44 * future Swing releases. The current serialization support is
45 * appropriate for short term storage or RMI between applications running
46 * the same version of Swing. As of 1.4, support for long term storage
47 * of all JavaBeans™
48 * has been added to the <code>java.beans</code> package.
49 * Please see {@link java.beans.XMLEncoder}.
50 *
51 * @param <E> the type of the elements of this model
52 *
53 * @author Hans Muller
54 */
55 @SuppressWarnings("serial") // Same-version serialization only
56 public class DefaultListModel<E> extends AbstractListModel<E>
57 {
58 private Vector<E> delegate = new Vector<E>();
59
60 /**
61 * Returns the number of components in this list.
62 * <p>
63 * This method is identical to <code>size</code>, which implements the
64 * <code>List</code> interface defined in the 1.2 Collections framework.
65 * This method exists in conjunction with <code>setSize</code> so that
66 * <code>size</code> is identifiable as a JavaBean property.
67 *
68 * @return the number of components in this list
69 * @see #size()
70 */
71 public int getSize() {
72 return delegate.size();
73 }
74
75 /**
|