commit | author | age
|
17820f
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
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
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
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.
|
|
15 |
*/
|
|
16 |
package com.gitblit.client;
|
|
17 |
|
|
18 |
import java.awt.Component;
|
|
19 |
import java.io.Serializable;
|
|
20 |
|
|
21 |
import javax.swing.JCheckBox;
|
|
22 |
import javax.swing.JTable;
|
|
23 |
import javax.swing.SwingConstants;
|
|
24 |
import javax.swing.table.TableCellRenderer;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Boolean checkbox cell renderer.
|
|
28 |
*
|
|
29 |
* @author James Moger
|
|
30 |
*
|
|
31 |
*/
|
|
32 |
public class BooleanCellRenderer extends JCheckBox implements TableCellRenderer, Serializable {
|
|
33 |
|
|
34 |
private static final long serialVersionUID = 1L;
|
|
35 |
|
|
36 |
public BooleanCellRenderer() {
|
|
37 |
super();
|
|
38 |
setOpaque(false);
|
|
39 |
setHorizontalAlignment(SwingConstants.CENTER);
|
|
40 |
}
|
|
41 |
|
|
42 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
|
43 |
boolean hasFocus, int row, int column) {
|
|
44 |
if (value instanceof Boolean) {
|
|
45 |
boolean checked = (Boolean) value;
|
|
46 |
this.setSelected(checked);
|
|
47 |
}
|
|
48 |
return this;
|
|
49 |
}
|
|
50 |
} |