ActionMapTableModel.java
资源名称:swingx.zip [点击查看]
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:1k
源码类别:
xml/soap/webservice
开发平台:
Java
- /*
- * $Id: ActionMapTableModel.java,v 1.1 2005/06/15 17:14:32 kleopatra Exp $
- *
- * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
- * Santa Clara, California 95054, U.S.A. All rights reserved.
- */
- package org.jdesktop.demo.swingx.common;
- import javax.swing.Action;
- import javax.swing.ActionMap;
- import javax.swing.table.AbstractTableModel;
- /**
- * Convenience TableMap showing all entries of a ActionMap.
- *
- * @author Jeanette Winzenburg
- */
- public class ActionMapTableModel extends AbstractTableModel {
- ActionMap actionMap;
- public ActionMapTableModel(ActionMap actionMap) {
- this.actionMap = actionMap;
- }
- public int getRowCount() {
- return actionMap.allKeys().length;
- }
- public int getColumnCount() {
- return 2;
- }
- public Object getValueAt(int rowIndex, int columnIndex) {
- Object key = actionMap.allKeys()[rowIndex];
- Action action = actionMap.get(key);
- switch (columnIndex) {
- case 0:
- return key;
- case 1:
- return action.getValue(Action.NAME);
- case 2:
- return action.getValue(Action.ACTION_COMMAND_KEY);
- default:
- return null;
- }
- }
- public String getColumnName(int column) {
- switch (column) {
- case 0:
- return "Key Name";
- case 1:
- return "Action Name";
- case 2:
- return "Action Command";
- default:
- return "Column " + column;
- }
- }
- }