📄 checkrenderer.java
字号:
/******************************************************************************
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP&CRM.
* The Initial Developer of the Original Code is Jorg Janke.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke.
* All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.minigrid;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import org.compiere.util.*;
import org.compiere.plaf.*;
/**
* Check Box Renderer based on Boolean values
*
* @author Jorg Janke
* @version $Id: CheckRenderer.java,v 1.3 2002/02/08 05:43:15 jjanke Exp $
*/
public final class CheckRenderer extends DefaultTableCellRenderer
{
/**
* Constructor
*/
public CheckRenderer()
{
super();
m_check.setMargin(new Insets(0,0,0,0));
m_check.setHorizontalAlignment(JLabel.CENTER);
} // CheckRenderer
private JCheckBox m_check = new JCheckBox();
/**
* Return centered, white Check Box
* @param table
* @param value
* @param isSelected
* @param hasFocus
* @param row
* @param col
* @return Component
*/
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int col)
{
// Editable ...
if (table.isCellEditable(row, col))
m_check.setBackground(CompierePLAF.getFieldBackground_Normal());
else
m_check.setBackground(CompierePLAF.getFieldBackground_Inactive());
// Value
setValue(value);
return m_check;
} // getTableCellRendererComponent
/**
* Set Value
* @param value
*/
public void setValue(Object value)
{
if (value != null && ((Boolean)value).booleanValue())
m_check.setSelected(true);
else
m_check.setSelected(false);
} // setValue
} // CheckRenderer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -