KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > contact > list > ContactList


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.contact.list;
17
18 import java.util.List JavaDoc;
19
20 import javax.swing.BorderFactory JavaDoc;
21 import javax.swing.JList JavaDoc;
22
23 import org.columba.addressbook.facade.IHeaderItem;
24
25
26
27 public class ContactList extends JList JavaDoc {
28     private ContactListModel model;
29
30     public ContactList(ContactListModel model) {
31         super(model);
32         this.model = model;
33
34         setCellRenderer(new ContactListRenderer());
35
36         setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
37     }
38
39     public ContactList() {
40         super();
41
42         model = new ContactListModel();
43         setModel(model);
44
45         setCellRenderer(new ContactListRenderer());
46
47         setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
48     }
49
50     public void setHeaderItemList(List JavaDoc<IHeaderItem> list) {
51         removeAll();
52
53         model.setHeaderItemList(list);
54     }
55
56     public void setModel(ContactListModel model) {
57         this.model = model;
58         super.setModel(model);
59     }
60
61     public void addElement(IHeaderItem item) {
62         model.addElement(item);
63     }
64
65     public IHeaderItem get(int index) {
66         IHeaderItem item = (IHeaderItem) model.get(index);
67
68         return item;
69     }
70 }
71
Popular Tags