001/**
002 * IntegerEditor.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 02/11/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.method.gui.editors;
010
011import java.util.Collection;
012
013import javax.swing.JComponent;
014import javax.swing.JTextField;
015
016/**
017 * Parameter Editor for Integer values.
018 * 
019 * @author Juan A. Recio-Garcia
020 * @version 1.0
021 * @see ParameterEditor
022 */
023public class IntegerEditor extends JTextField implements ParameterEditor {
024
025        private static final long serialVersionUID = 1L;
026
027        /**
028         *  Creates a new instance
029         */
030        public IntegerEditor() {
031            super();
032        }
033        
034
035        /**
036         * Returns an Integer object
037         */
038        public Object getEditorValue() {
039            try{
040                return new Integer(getText());
041            }catch(Exception e){}
042            return null;
043        }
044
045        /**
046         * Returns the JComponent
047         */
048        public JComponent getJComponent() {
049                return (JComponent) this;
050        }
051
052        /**
053         * Receives an Integer value
054         */
055        public void setEditorValue(Object value) {
056                if(value == null)
057                {
058                    this.setText("");
059                    return;
060                }
061                this.setText(value.toString());
062        }
063
064        /**
065         * Does nothing
066         */
067        public void setAllowedValues(Collection<Object> allowedValues)
068        {
069            // ANY
070        }
071
072}