tabs: fixing invalidation on tab property changes
[fedora-idea.git] / platform / platform-api / src / com / intellij / ui / BooleanTableCellRenderer.java
blob720e4c1e2c04de959d2d039812d13d4d0fafef11
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /**
18 * created at Oct 5, 2001
19 * @author Jeka
21 package com.intellij.ui;
23 import javax.swing.*;
24 import javax.swing.table.TableCellRenderer;
25 import java.awt.*;
27 public class BooleanTableCellRenderer extends JCheckBox implements TableCellRenderer {
28 private final JPanel myPanel = new JPanel();
30 public BooleanTableCellRenderer() {
31 super();
32 setHorizontalAlignment(JLabel.CENTER);
35 public Component getTableCellRendererComponent(JTable table, Object value,
36 boolean isSelected, boolean hasFocus,
37 int row, int column) {
38 if(value == null) {
39 if(isSelected) {
40 myPanel.setBackground(table.getSelectionBackground());
42 else {
43 myPanel.setBackground(table.getBackground());
45 return myPanel;
47 if(isSelected) {
48 setForeground(table.getSelectionForeground());
49 super.setBackground(table.getSelectionBackground());
51 else {
52 setForeground(table.getForeground());
53 setBackground(table.getBackground());
55 if (value instanceof String) {
56 setSelected(Boolean.parseBoolean((String)value));
58 else {
59 setSelected(((Boolean)value).booleanValue());
61 return this;