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

📄 propertytablemodel.java

📁 自动生成JAVA-Struts网站的程序
💻 JAVA
字号:
package com.sutternow.swingkar.gui;import javax.swing.table.AbstractTableModel;import javax.swing.*;import java.util.Set;import java.util.Iterator;import java.util.Map;import java.util.HashMap;import java.awt.*;/** * Created by IntelliJ IDEA. * User: sergei * Date: Apr 30, 2003 * Time: 1:22:37 AM * To change this template use Options | File Templates. */public class PropertyTableModel extends AbstractTableModel {    /**     * Constructs an AppList table model.     * @param _appSet  the collection of extentions and associations     */    String[] colNames ={"Name", "Value"};    public PropertyTableModel(Set _appSet) {        appSet = _appSet;    }   public PropertyTableModel(Set _appSet, String colOneName, String colTwoName) {       colNames[0] = colOneName;       colNames[1] = colTwoName;       appSet = _appSet;    }    public int getRowCount() {        return appSet.size();    }    public void requestRefresh() {        /* Used to refresh the table */        super.fireTableDataChanged();    }    public int getColumnCount() {        return 2;    }    public void setValueAt(Object aValue, int r, int c) {           Map m = new HashMap();          Iterator iter = appSet.iterator();          int iCurrentRow = 0;          while (iter.hasNext()) {              Map.Entry entry = (Map.Entry) iter.next();              if (iCurrentRow == r) {                  if( c == 1) {                      //todo fill this out appSet.re                       //(String)entry.getKey() =(String)aValue;                  } else if (c==2) {                      entry.setValue((String)aValue);                  }                  entry.getValue();              }              iCurrentRow++;          }      }    public Object getValueAt(int r, int c) {        Iterator iter = appSet.iterator();        int iCurrentRow = 0;        while (iter.hasNext()) {            Map.Entry entry = (Map.Entry) iter.next();            if (iCurrentRow == r)                switch (c) {                    case 0:                        return entry.getKey();                    case 1:                        return entry.getValue();                }            iCurrentRow++;        }        return "no value dude";    }    public String getColumnName(int c) {        return colNames[c];    }    private Set appSet;} //}}}

⌨️ 快捷键说明

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