1 19 package org.lucane.applications.jmail.base; 20 21 import java.awt.*; 22 import javax.swing.*; 23 import javax.swing.tree.*; 24 25 import org.lucane.applications.jmail.JMailPlugin; 26 27 public class FolderRenderer extends DefaultTreeCellRenderer 28 { 29 private JMailPlugin plugin; 30 private Icon inboxIcon; 31 private Icon sentIcon; 32 private Icon draftsIcon; 33 private Icon trashIcon; 34 private Icon openedFolderIcon; 35 private Icon closedFolderIcon; 36 37 public FolderRenderer(JMailPlugin plugin) 38 { 39 this.plugin = plugin; 40 this.inboxIcon = plugin.getImageIcon("folders/inbox.png"); 41 this.sentIcon = plugin.getImageIcon("folders/sent.png"); 42 this.draftsIcon = plugin.getImageIcon("folders/drafts.png"); 43 this.trashIcon = plugin.getImageIcon("folders/trash.png"); 44 this.openedFolderIcon = plugin.getImageIcon("folders/openedFolder.png"); 45 this.closedFolderIcon = plugin.getImageIcon("folders/closedFolder.png"); 46 } 47 48 public Component getTreeCellRendererComponent(JTree tree, 49 Object value, boolean sel, boolean expanded, boolean leaf, 50 int row, boolean hasFocus) 51 { 52 JLabel label = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); 53 54 if(value.toString().equalsIgnoreCase("Mailbox")) 56 { 57 label.setText("<html><b>" +tr("folder.root") + "</b></html>"); 58 label.setIcon(null); 59 } 60 else if(value.toString().equalsIgnoreCase("INBOX")) 62 { 63 label.setText(tr("folder.inbox")); 64 label.setIcon(this.inboxIcon); 65 } 66 else if(value.toString().equalsIgnoreCase("Sent")) 67 { 68 label.setText(tr("folder.sent")); 69 label.setIcon(this.sentIcon); 70 } 71 else if(value.toString().equalsIgnoreCase("Drafts")) 72 { 73 label.setText(tr("folder.drafts")); 74 label.setIcon(this.draftsIcon); 75 } 76 else if(value.toString().equalsIgnoreCase("Trash")) 77 { 78 label.setText(tr("folder.trash")); 79 label.setIcon(this.trashIcon); 80 } 81 82 else if(expanded) 84 label.setIcon(this.openedFolderIcon); 85 else 86 label.setIcon(this.openedFolderIcon); 87 88 return label; 89 } 90 91 private String tr(String s) 92 { 93 return plugin.tr(s); 94 } 95 } | Popular Tags |