Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
ComboBoxCellRenderer |
|
| 1.0;1 |
1 | /* |
|
2 | Wotonomy: OpenStep design patterns for pure Java applications. |
|
3 | Copyright (C) 2000 Intersect Software Corporation |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, see http://www.gnu.org |
|
17 | */ |
|
18 | ||
19 | package net.wotonomy.ui.swing.components; |
|
20 | ||
21 | import java.awt.Color; |
|
22 | import java.awt.Component; |
|
23 | ||
24 | import javax.swing.JComboBox; |
|
25 | import javax.swing.JTable; |
|
26 | import javax.swing.table.TableCellRenderer; |
|
27 | ||
28 | /** |
|
29 | * A TableCellRenderer that paints a JComboBox. Useful if |
|
30 | * you want to visibly display the JComboBox before the |
|
31 | * user clicks on the cell. |
|
32 | * |
|
33 | * @author bsafa@intersectsoft.com |
|
34 | * @author $Author: cgruber $ |
|
35 | * @version $Revision: 904 $ |
|
36 | */ |
|
37 | public class ComboBoxCellRenderer extends JComboBox implements TableCellRenderer { |
|
38 | ||
39 | public ComboBoxCellRenderer() |
|
40 | { |
|
41 | 0 | super(); |
42 | 0 | setOpaque(true); |
43 | 0 | } |
44 | ||
45 | public Component getTableCellRendererComponent( |
|
46 | JTable table, Object value, |
|
47 | boolean isSelected, boolean hasFocus, |
|
48 | int row, int column) |
|
49 | { |
|
50 | 0 | setBackground(Color.white); |
51 | 0 | setSelectedItem(value); |
52 | 0 | return this; |
53 | } |
|
54 | } |
|
55 | ||
56 | ||
57 |