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

📄 sqlstatecodescellrenderer.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
字号:
/* * SQLStateCodesCellRenderer.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.executequery.gui.sqlstates;import java.awt.Component;import java.awt.Font;import javax.swing.JLabel;import javax.swing.JTable;import javax.swing.table.TableCellRenderer;import org.executequery.Constants;/* ---------------------------------------------------------- * 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.1 $ * @date     $Date: 2006/06/14 15:06:44 $ */public class SQLStateCodesCellRenderer extends JLabel                                        implements TableCellRenderer {    private static Font classHeaderFont;        /** Creates a new instance of KeywordCellRenderer */    public SQLStateCodesCellRenderer() {        sb = new StringBuffer();    }        public Component getTableCellRendererComponent(JTable table,                                                   Object value,                                                   boolean isSelected,                                                   boolean cellHasFocus,                                                   int row,                                                    int col) {        if (classHeaderFont == null) {            Font font = table.getFont();            classHeaderFont = font.deriveFont(Font.BOLD);        }                SQLStateCode code = (SQLStateCode)value;        setToolTipText(buildToolTip(code));                String subClass = code.getSqlStateSubClass();        if (subClass.equals("000")) {            setFont(classHeaderFont);        } else {            setFont(table.getFont());        }                switch (col) {            case 0:                setText(code.getSqlStateClass());                setHorizontalAlignment(JLabel.CENTER);                break;            case 1:                setText(code.getSqlStateSubClass());                setHorizontalAlignment(JLabel.CENTER);                break;            case 2:                setText(code.getDescription());                break;        }        if (isSelected) {            setBackground(table.getSelectionBackground());            setForeground(table.getSelectionForeground());        } else {            setBackground(table.getBackground());            setForeground(table.getForeground());        }        return this;    }        /** tool tip concat buffer */    private StringBuffer sb;        private String buildToolTip(SQLStateCode code) {        // reset        sb.setLength(0);                // build the html display        sb.append("<html>");        sb.append(Constants.TABLE_TAG_START);        sb.append("<tr><td><b>SQL State Code: ");        sb.append(code.getSqlStateClass());        sb.append("-");        sb.append(code.getSqlStateSubClass());        sb.append("</b></td></tr>");        sb.append(Constants.TABLE_TAG_END);        sb.append("<hr>");        sb.append(Constants.TABLE_TAG_START);        sb.append(code.getDescription());        sb.append("</td></tr>");        sb.append(Constants.TABLE_TAG_END);        sb.append("</html>");        return sb.toString();    }        public boolean isOpaque() {        return true;    }}

⌨️ 快捷键说明

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