1 package org.wcb.common; 2 3 import javax.swing.*; 4 import java.awt.*; 5 import java.awt.event.ActionListener; 6 import java.awt.event.ActionEvent; 7 8 /*** 9 * Copyright (C) 2003 Walter Bogaardt 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 24 * 25 * Project: Home Automation Interface 26 * 27 * Abstract: User Interface options dialog box 28 * Filename: $Id: FontCellEditor.java,v 1.3 2004/01/08 15:06:29 wbogaardt Exp $ 29 * 30 * * $Log: FontCellEditor.java,v $ 31 * * Revision 1.3 2004/01/08 15:06:29 wbogaardt 32 * * refactored the email, color, font, and general panels out of the UIDialog Panel. 33 * * 34 * * Revision 1.2 2003/12/30 22:15:59 wbogaardt 35 * * added javadoc comments 36 * * 37 */ 38 public class FontCellEditor extends DefaultCellEditor { 39 40 public Font currentFont = null; 41 42 public FontCellEditor(JButton b) { 43 super(new JCheckBox()); 44 editorComponent = b; 45 setClickCountToStart(1); 46 b.addActionListener(new ActionListener() { 47 public void actionPerformed(ActionEvent e) { 48 fireEditingStopped(); 49 } 50 }); 51 } 52 53 protected void fireEditingStopped() { 54 super.fireEditingStopped(); 55 } 56 57 public Object getCellEditorValue() { 58 return currentFont; 59 } 60 61 public Component getTableCellEditorComponent(JTable table, 62 Object value, 63 boolean isSelected, 64 int row, 65 int column) { 66 ((JButton)editorComponent).setText(value.toString()); 67 currentFont = (Font)value; 68 return editorComponent; 69 } 70 }