1 package com.explosion.utilities.preferences.editandrender.table;
2
3 /*
4 * =============================================================================
5 *
6 * Copyright 2004 Stephen Cowx
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 * use this file except in compliance with the License. You may obtain a copy of
10 * the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 * =============================================================================
21 */
22
23 import java.awt.Component;
24
25 import javax.swing.JTable;
26 import javax.swing.table.DefaultTableCellRenderer;
27 import javax.swing.table.TableCellRenderer;
28
29 import com.explosion.utilities.preferences.Preference;
30
31 public class FontPreferenceRenderer extends DefaultTableCellRenderer implements TableCellRenderer
32 {
33
34 public FontPreferenceRenderer()
35 {
36 super();
37 }
38
39 public Component getTableCellRendererComponent(JTable table, Object preference, boolean isSelected, boolean hasFocus, int row, int column)
40 {
41 /* Set up the value for the column */
42 Preference pref = (Preference) preference;
43 Object renderableValue = pref.getValue();
44 if (renderableValue == null && pref.getDefaultValue() != null) renderableValue = pref.getDefaultValue();
45
46 if (renderableValue == null)
47 setText("");
48 else
49 setText(pref.toString());
50
51 return this;
52 }
53 }