xfiletablecellrenderer.java
来自「JavaExplorer是一个独立于平台的浏览器」· Java 代码 · 共 132 行
JAVA
132 行
/** * File and FTP Explorer * Copyright 2003 * BOESCH Vincent * * 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 (at your option) 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 javaexplorer.gui.renderer;import java.awt.Component;import javaexplorer.model.XFile;import javaexplorer.ressource.MagicNumber;import javaexplorer.util.*;import javaexplorer.util.filter.*;import javax.swing.*;import javax.swing.table.DefaultTableCellRenderer;public class XFileTableCellRenderer extends DefaultTableCellRenderer { ImageFilter fif = new ImageFilter(); private boolean _booShowPath = false; public XFileTableCellRenderer() { this(false); } public XFileTableCellRenderer(boolean booShowPath) { super(); noFocusBorder = null; setBorder(noFocusBorder); _booShowPath = booShowPath; } /** * Gets the TreeCellRendererComponent * attribute of the ImageTreeCellRenderer * object * *@param value Description of * Parameter *@param list Description of * the Parameter *@param index Description of * the Parameter *@param isSelected Description of * the Parameter *@param cellHasFocus Description of * the Parameter *@return The TreeCellRendererComponent * value */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isSelected) { setBackground(table.getBackground().darker()); setForeground(table.getForeground()); } else { setBackground(table.getBackground()); setForeground(table.getForeground()); } if( value instanceof XFileTableFiler ){ if (column == 0) { ImageIcon ii = MagicNumber.getIconForXFile(((XFile) value)); if (ii != null) { setIcon(ii); } setText(_booShowPath ? ((XFile) value).getPath() : ((XFile) value).getName()); } else{ setIcon(null); setText(""); } } else if (value instanceof XFile) { setForeground(XFileUtil.getXFileColor(((XFile)value))); // Nom et icone if (column == 0) { ImageIcon ii = MagicNumber.getIconForXFile(((XFile) value)); if (ii != null) { setIcon(ii); } setText(_booShowPath ? ((XFile) value).getPath() : ((XFile) value).getName()); } // Taille if (column == 1) { setText(ExplorerUtil.getLengthAsString(((XFile) value).length())); setIcon(null); } //Date if (column == 2) { setText(DateUtil.formatDate(((XFile) value).lastModified())); setIcon(null); } } else { setText(value.toString()); } setFont(table.getFont()); setBorder((hasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); return this; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?