KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > config > classpath > ClasspathCellRenderer


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.browser.config.classpath;
9
10 import javax.swing.*;
11 import java.awt.*;
12
13 /**
14     Cell renderer for the list in the <tt>ClasspathSetupDialog</tt>.
15
16     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
17     @version $Revision: 1.1 $ $Date: 2003/08/18 08:10:15 $
18 */

19 public class ClasspathCellRenderer extends DefaultListCellRenderer {
20
21     public Component getListCellRendererComponent(
22             JList list,
23             Object JavaDoc value,
24             int index,
25             boolean isSelected,
26             boolean cellHasFocus)
27     {
28         ClasspathEntry entry = (ClasspathEntry)value;
29         super.getListCellRendererComponent(list, entry.getFileName(), index, isSelected, cellHasFocus);
30
31         Icon icon;
32         if (entry instanceof ClasspathDirectoryEntry) {
33             icon = UIManager.getIcon("FileView.directoryIcon");
34         } else {
35             icon = UIManager.getIcon("FileView.fileIcon");
36         }
37         setIcon(icon);
38
39         return this;
40     }
41 }
42
Popular Tags