1 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 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 [] data) 57 { 58 Object [] myData = new Object [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 getAuthor() 69 { 70 return (String )list.getSelectedValue(); 71 } 72 } 73 | Popular Tags |