All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.ide.common.swing.CheckBoxRenderer Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20240823
Show newest version
package com.scudata.ide.common.swing;

import java.awt.Component;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.scudata.ide.common.GM;

/**
 * JTable??Ԫ??ѡ????Ⱦ??
 *
 */
public class CheckBoxRenderer extends JCheckBox implements TableCellRenderer {

	private static final long serialVersionUID = 1L;

	/**
	 * ???캯??
	 */
	public CheckBoxRenderer() {
		setHorizontalAlignment(JLabel.CENTER);
	}

	/**
	 * ???ر༭?ؼ?
	 */
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		if (isSelected) {
			setForeground(table.getSelectionForeground());
			setBackground(table.getSelectionBackground());
		} else {
			setForeground(table.getForeground());
			setBackground(table.getBackground());
		}
		if (value == null || !(value instanceof Boolean)) {
			value = new Boolean(false);
		}
		try {
			setSelected(((Boolean) value).booleanValue());
		} catch (Exception e) {
			GM.showException(e);
		}
		return this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy