KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > gui > list > AddressbookListView


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.addressbook.gui.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.model.IBasicModelPartial;
24
25
26
27 public class AddressbookListView extends JList JavaDoc {
28     private AddressbookListModel model;
29
30     public AddressbookListView(AddressbookListModel model) {
31         super(model);
32         
33         this.model = model;
34
35         //setCellRenderer(new AddressbookListRenderer());
36

37         setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
38     }
39
40     public AddressbookListView() {
41         super();
42
43         model = new AddressbookListModel();
44         setModel(model);
45
46         //setCellRenderer(new AddressbookListRenderer());
47

48         setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
49     }
50
51     public void setHeaderItemList(List JavaDoc<IBasicModelPartial> list) {
52         removeAll();
53
54         model.setHeaderItemList(list);
55     }
56
57     public void setModel(AddressbookListModel model) {
58         this.model = model;
59         super.setModel(model);
60     }
61
62     public void addElement(IBasicModelPartial item) {
63         model.addElement(item);
64     }
65
66     public IBasicModelPartial get(int index) {
67         IBasicModelPartial item = (IBasicModelPartial) model.get(index);
68
69         return item;
70     }
71 }
72
Popular Tags