<commit_before>package org.swingeasy;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6723524
 */
public class BooleanTableCellRenderer extends DefaultTableCellRenderer {
    private static final long serialVersionUID = 2577869717107398445L;

    private JCheckBox renderer;

    public BooleanTableCellRenderer() {
        this.renderer = new JCheckBox();
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        Boolean b = (Boolean) value;
        if (b != null) {
            this.renderer.setSelected(b);
        } else {
            this.renderer.setSelected(false);
        }
        if (isSelected) {
            this.renderer.setForeground(table.getSelectionForeground());
            this.renderer.setBackground(table.getSelectionBackground());
        } else {
            Color bg = this.getBackground();
            this.renderer.setForeground(this.getForeground());
            // We have to create a new color object because Nimbus returns
            // a color of type DerivedColor, which behaves strange, not sure
            // why.
            this.renderer.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
            this.renderer.setOpaque(true);
        }
        return this.renderer;
    }
}<commit_msg>render boolean editor is now centered<commit_after>package org.swingeasy;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6723524
 */
public class BooleanTableCellRenderer extends DefaultTableCellRenderer {
    private static final long serialVersionUID = 2577869717107398445L;

    private JCheckBox renderer;

    public BooleanTableCellRenderer() {
        this.renderer = new JCheckBox();
        this.renderer.setHorizontalAlignment(SwingConstants.CENTER);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        Boolean b = (Boolean) value;
        if (b != null) {
            this.renderer.setSelected(b);
        } else {
            this.renderer.setSelected(false);
        }
        if (isSelected) {
            this.renderer.setForeground(table.getSelectionForeground());
            this.renderer.setBackground(table.getSelectionBackground());
        } else {
            Color bg = this.getBackground();
            this.renderer.setForeground(this.getForeground());
            // We have to create a new color object because Nimbus returns
            // a color of type DerivedColor, which behaves strange, not sure
            // why.
            this.renderer.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
            this.renderer.setOpaque(true);
        }
        return this.renderer;
    }
}
{'fraction_non_alphanumeric': 0.09828807556080284, 'fraction_numerical': 0.015348288075560802, 'mean_word_length': 2.877574370709382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611576', 'n_tokens_mistral': 947, 'n_tokens_neox': 922, 'n_words': 212}