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

📄 vocabularytablemodel.java

📁 辞典 这个是同学们一起编的一个辞典 JAVA开发的 希望能有用
💻 JAVA
字号:
package com.ui.table;import javax.swing.table.AbstractTableModel;import java.util.SortedMap;import javax.swing.table.TableModel;import java.util.TreeMap;import com.io.file.VocabularyFileReader;/** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2008</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */public class VocabularyTableModel extends AbstractTableModel{    private SortedMap sortedMap = null;    private Object[] vocabulary = null;    private Object[] pronounce = null;    public VocabularyTableModel(SortedMap map)    {        if (map != null)        {            this.setSortedMap(map);            this.vocabulary = this.sortedMap.keySet().toArray();            this.pronounce = this.sortedMap.values().toArray();        }        else        {            this.setSortedMap(new TreeMap(new VocabularyFileReader("/opt/work/workspace/jb6/JDic/src/jdic/default.voc", "").getMap()));            this.vocabulary = this.sortedMap.keySet().toArray();            this.pronounce = this.sortedMap.values().toArray();        }    }    public SortedMap getSortedMap()    {        return this.sortedMap;    }    public void setSortedMap(SortedMap map)    {        this.sortedMap = map;    }    public int getColumnCount()    {        return 2;    }    public int getRowCount()    {        return vocabulary.length;    }    public String getColumnName(int colIndex)    {        switch (colIndex)        {            case 0:                return "VOCABULARY";            case 1:                return "PRONOUNCE";            default:                return "";        }    }    public boolean isCellEditable(int rowIndex, int columnIndex)    {        if (columnIndex == 0)        {            return false;        }        else        {            return true;        }    }    public Object getValueAt(int row, int col)    {        if (col == 0)        {            return this.vocabulary[row];        }        else        {            String pronounciation = this.pronounce[row].toString().trim();            pronounciation = pronounciation.substring(pronounciation.indexOf("[ "));            //System.out.println(pronounciation);            char[] ccc = pronounciation.toCharArray();            for (int i = 0; i < ccc.length; i++)            {                int j = ccc[i];                //System.out.print(j + " ");            }            //System.out.println();            return pronounciation;        }    }}

⌨️ 快捷键说明

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