Package miage.jtreeindex

Source Code of miage.jtreeindex.PersonnalTreeCellRenderer

package miage.jtreeindex;

import java.awt.Component;
import java.io.File;
import java.util.ArrayList;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import entagged.tageditor.resources.ResourcesRepository;

import miage.sgbd.DataProvider;

public class PersonnalTreeCellRenderer extends DefaultTreeCellRenderer {

  public static ArrayList<String> AL = new ArrayList<String>();
 
  public PersonnalTreeCellRenderer(){
    AL = DataProvider.getDossier();
  }
 
    public Component getTreeCellRendererComponent(
            JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
            int row, boolean hasFocus) {

      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    DefaultMutableTreeNode Df = (DefaultMutableTreeNode) value;
    String nom = ((File)Df.getUserObject()).getAbsolutePath();
      if (AL.contains(nom))
      {
        ImageIcon icon = ResourcesRepository.getImageIcon("index.gif");
        setIcon(icon);
      }
      else {
        ImageIcon icon = ResourcesRepository.getImageIcon("noindex.gif");
        setIcon(icon);
      }
      //System.out.println(value.toString());
      return this;
    }
}
TOP

Related Classes of miage.jtreeindex.PersonnalTreeCellRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.