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

📄 eachroweditor.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
字号:
/* * EachRowEditor.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.underworldlabs.swing.table;import java.awt.Component;import java.awt.event.MouseEvent;import java.util.EventObject;import java.util.Hashtable;import javax.swing.DefaultCellEditor;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.event.CellEditorListener;import javax.swing.table.TableCellEditor;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.4 $ * @date     $Date: 2006/05/14 06:56:07 $ */public class EachRowEditor implements TableCellEditor {        protected Hashtable editors;    protected TableCellEditor editor;    protected TableCellEditor defaultEditor;    protected JTable table;        /**     * Constructs a EachRowEditor.     * create default editor     *     * @see TableCellEditor     * @see DefaultCellEditor     */    public EachRowEditor(JTable table) {        this.table = table;        editors = new Hashtable();        JTextField defaultField = new JTextField();        defaultField.setBorder(null);        defaultEditor = new DefaultCellEditor(defaultField);    }        /**     * @param row    table row     * @param editor table cell editor     */    public void setEditorAt(int row, TableCellEditor editor) {        editors.put(new Integer(row),editor);    }        public Component getTableCellEditorComponent(JTable table,                                                 Object value,                                                  boolean isSelected,                                                  int row,                                                  int column) {                Component _editor = editor.getTableCellEditorComponent(                                      table, value, isSelected, row, column);        _editor.setFont(table.getFont());        return _editor;    }        public Object getCellEditorValue() {        return editor.getCellEditorValue();    }    public boolean stopCellEditing() {        return editor.stopCellEditing();    }    public void cancelCellEditing() {        editor.cancelCellEditing();    }    public boolean isCellEditable(EventObject anEvent) {        selectEditor((MouseEvent)anEvent);        return editor.isCellEditable(anEvent);    }    public void addCellEditorListener(CellEditorListener l) {        editor.addCellEditorListener(l);    }    public void removeCellEditorListener(CellEditorListener l) {        editor.removeCellEditorListener(l);    }    public boolean shouldSelectCell(EventObject anEvent) {        selectEditor((MouseEvent)anEvent);        return editor.shouldSelectCell(anEvent);    }        protected void selectEditor(MouseEvent e) {        int row;        if (e == null) {            row = table.getSelectionModel().getAnchorSelectionIndex();        } else {            row = table.rowAtPoint(e.getPoint());        }        editor = (TableCellEditor)editors.get(new Integer(row));        if (editor == null) {            editor = defaultEditor;        }    }}

⌨️ 快捷键说明

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