KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > gui > main > AuthorListPanel


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2003 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19  
20 package org.lucane.applications.notes.gui.main;
21
22 import org.lucane.applications.notes.*;
23
24 import java.awt.*;
25 import javax.swing.*;
26 import javax.swing.event.*;
27
28 class AuthorListPanel extends JPanel
29 {
30     private JLabel label;
31     private JList list;
32     
33     private SpecialElement myNotes;
34     private SpecialElement recentNotes;
35     
36     
37     public AuthorListPanel(NotesPlugin parent, ListSelectionListener listener)
38     {
39         //panel config
40
super();
41         this.setLayout(new BorderLayout());
42     
43         this.label = new JLabel(parent.tr("main.authors"));
44         this.list = new JList();
45         this.add(label, BorderLayout.NORTH);
46         this.add(list, BorderLayout.CENTER);
47         
48         this.myNotes = new SpecialElement("myNotes", parent.tr("main.myNotes"));
49         this.recentNotes = new SpecialElement("recentNotes", parent.tr("main.recentNotes"));
50
51         list.setName("authors");
52         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
53         list.addListSelectionListener(listener);
54     }
55     
56     public void setListData(Object JavaDoc[] data)
57     {
58         Object JavaDoc [] myData = new Object JavaDoc[data.length +2];
59         myData[0] = recentNotes;
60         myData[1] = myNotes;
61         
62         for(int i=0;i<data.length;i++)
63             myData[i+2] = data[i];
64         
65         list.setListData(myData);
66     }
67     
68     public String JavaDoc getAuthor()
69     {
70         return (String JavaDoc)list.getSelectedValue();
71     }
72 }
73
Popular Tags