1 package net.sf.jftp.gui.base.dir; 2 3 import java.util.Vector ; 4 5 import javax.swing.JTable ; 6 import javax.swing.event.ListSelectionEvent ; 7 import javax.swing.event.ListSelectionListener ; 8 9 import net.sf.jftp.config.Settings; 10 11 12 public class DirComponent extends DirPanel implements ListSelectionListener { 13 14 public JTable table = new JTable (); 15 DirPanel target; 16 17 public DirComponent() { 18 19 table.setDefaultRenderer(Object .class, new ColoredCellRenderer()); 20 table.getSelectionModel().addListSelectionListener(this); 21 22 table.setRowSelectionAllowed(true); 24 table.setColumnSelectionAllowed(false); 25 } 26 27 public void update() { 28 if(Settings.getUseJTableLayout()) { 29 Vector colNames = new Vector (); 30 colNames.add(""); 31 colNames.add("Name"); 32 colNames.add("Size"); 33 colNames.add("##"); 34 35 TableUtils.layoutTable(jl, table, colNames); 36 } 37 } 38 39 42 public void valueChanged(ListSelectionEvent e) 43 { 44 if(e.getValueIsAdjusting() == false) 45 { 46 if(Settings.getUseJTableLayout()) { 47 TableUtils.copyTableSelectionsToJList(jl, table); 48 } 49 50 int index = jl.getSelectedIndex() - 1; 52 53 if((index < 0) || (dirEntry == null) || (dirEntry.length < index) || 54 (dirEntry[index] == null)) 55 { 56 return; 57 } 58 else 59 { 61 String tgt = (String ) jl.getSelectedValue().toString(); 62 63 for(int i = 0; i < dirEntry.length; i++) 64 { 65 dirEntry[i].setSelected(jl.isSelectedIndex(i + 1)); 66 } 67 } 68 } 69 } 70 71 72 } 73 | Popular Tags |