KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > SDefaultListModel


1 /*
2  * $Id: SDefaultListModel.java,v 1.3 2004/12/01 07:54:07 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings;
15
16 import javax.swing.*;
17 import java.util.ArrayList JavaDoc;
18 import java.util.List JavaDoc;
19
20 /**
21  * @author <a HREF="mailto:haaf@mercatis.de">Armin Haaf</a>
22  * @version $Revision: 1.3 $
23  */

24 public class SDefaultListModel
25         extends AbstractListModel {
26     protected final ArrayList JavaDoc data = new ArrayList JavaDoc(2);
27
28
29     public SDefaultListModel(List JavaDoc d) {
30         data.clear();
31         if (d != null) {
32             for (int i = 0; i < d.size(); i++)
33                 data.add(d.get(i));
34         }
35     }
36
37
38     public SDefaultListModel(Object JavaDoc[] d) {
39         data.clear();
40         if (d != null) {
41             for (int i = 0; i < d.length; i++)
42                 data.add(d[i]);
43         }
44     }
45
46
47     public SDefaultListModel() {
48     }
49
50
51     public int getSize() {
52         return data.size();
53     }
54
55
56     public Object JavaDoc getElementAt(int i) {
57         return data.get(i);
58     }
59
60 }
61
62
63
Popular Tags