📄 propertynamecellrenderer.java
字号:
/*
* 08/10/2005
*
* PropertyNameCellRenderer.java - Renderer for property names.
* Copyright (C) 2005 Robert Futrell
* email@address.com
* www.website.com
*
* 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.fife.ui.propertysheet.renderers;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import org.fife.ui.propertysheet.infos.PropertyInfo;
/**
* Renderer for property names. This class writes the names of modified
* properties in bold.
*
* @author Robert Futrell
* @version 1.0
*/
public class PropertyNameCellRenderer extends DefaultTableCellRenderer {
/**
*
*/
private static final long serialVersionUID = -1461356003960084503L;
/*****************************************************************************/
/**
* Returns the font to use for a modified property.
*
* @return The font.
*/
protected Font createDerivedFont() {
// Toggle the boldness (in case you are using an odd UI such as some
// Ocean theme that uses a bold font as the default for labels).
Font font = getFont();
font = font.deriveFont(font.getStyle()^Font.BOLD);
return font;
}
/*****************************************************************************/
/**
* Returns the component with which to renderer property names.
*/
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
setFont(UIManager.getFont("Label.font")); // Set default font.
PropertyInfo info = (PropertyInfo)table.getValueAt(row, 1);
Object propValue = info.getValue();
Object propDefaultValue = info.getDefaultValue();
if (propValue!=null && !propValue.equals(propDefaultValue))
setFont(createDerivedFont());
setEnabled(info.isModifiable());
return this;
}
/*****************************************************************************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -