⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nettablemodel.java

📁 Java实现的explorer程序
💻 JAVA
字号:
/*
 * NetTableModel.java
 *
 * Created on 2007年8月8日, 下午5:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package explorer;

import java.util.*;
import javax.swing.table.*;

/**
 *
 * @author king
 */
public class NetTableModel extends AbstractTableModel {
    Vector<String> theFiles;
    String[] title;
    Object content[][];
    Class columnType[];
    /** Creates a new instance of NetTableModel */
    public NetTableModel(){
        columnType = new Class[]{String.class,String.class,String.class,String.class};
        title = new String[]{"文件名","文件大小","文件类型","修改日期"};
        content = new Object[0][0];
    }
    public NetTableModel(Vector<String> file) {
        theFiles = file;
        columnType = new Class[]{String.class,String.class,String.class,String.class};
        title = new String[]{"文件名","文件大小","文件类型","修改日期"};
        this.initialContent();
    }
    
    public int getColumnCount(){
        return this.title.length;
    }
    
    public int getRowCount(){
        return this.content.length;
    }
    
    public Object getValueAt(int row,int col){
        return content[row][col];
    }
    
    public String getColumnName(int col){
        return title[col];
    }
    
    public Class getColumnClass(int col){
        return columnType[col];
    }
    
    public void initialContent(){
        content = new Object[theFiles.size()-1][title.length];
        int low = -1;
        int high = -1;
        for (int i=0;i<theFiles.size()-1;i++)
        {
            high = theFiles.get(i).length();
            low = theFiles.get(i).lastIndexOf(';',high);
            content[i][3] = theFiles.get(i).substring(low+1,high);
            high = low-1;
            low = theFiles.get(i).lastIndexOf(';',high);
            content[i][2] = theFiles.get(i).substring(low+1,high+1);
            high = low-1;
            low = theFiles.get(i).lastIndexOf(';',high);
            content[i][1] = theFiles.get(i).substring(low+1,high+1) + "字节";
            content[i][0] = theFiles.get(i).substring(0,low);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -