ActionMapTableModel.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:1k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: ActionMapTableModel.java,v 1.1 2005/06/15 17:14:32 kleopatra Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  */
  7. package org.jdesktop.demo.swingx.common;
  8. import javax.swing.Action;
  9. import javax.swing.ActionMap;
  10. import javax.swing.table.AbstractTableModel;
  11. /**
  12.  * Convenience TableMap showing all entries of a ActionMap.
  13.  * 
  14.  * @author Jeanette Winzenburg
  15.  */
  16. public class ActionMapTableModel extends AbstractTableModel {
  17.     ActionMap actionMap;
  18.     public ActionMapTableModel(ActionMap actionMap) {
  19.         this.actionMap = actionMap;
  20.     }
  21.     public int getRowCount() {
  22.         return actionMap.allKeys().length;
  23.     }
  24.     public int getColumnCount() {
  25.         return 2;
  26.     }
  27.     public Object getValueAt(int rowIndex, int columnIndex) {
  28.         Object key = actionMap.allKeys()[rowIndex];
  29.         Action action = actionMap.get(key);
  30.         switch (columnIndex) {
  31.         case 0:
  32.             return key;
  33.         case 1:
  34.             return action.getValue(Action.NAME);
  35.         case 2:
  36.             return action.getValue(Action.ACTION_COMMAND_KEY);
  37.         default:
  38.             return null;
  39.         }
  40.     }
  41.     public String getColumnName(int column) {
  42.         switch (column) {
  43.         case 0:
  44.             return "Key Name";
  45.         case 1:
  46.             return "Action Name";
  47.         case 2:
  48.             return "Action Command";
  49.         default:
  50.             return "Column " + column;
  51.         }
  52.     }
  53. }