DataModelToComboBoxModelAdapter.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:2k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id $Exp
  3.  * Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle,
  4.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2.1 of the License, or (at your option) any later version.
  10.  * 
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  * 
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  19.  */
  20. package org.jdesktop.binding.swingx.adapter;
  21. import javax.swing.ComboBoxModel;
  22. import org.jdesktop.binding.TabularDataModel;
  23. /**
  24.  * @author (C) 2004 Jeanette Winzenburg, Berlin
  25.  * @version $Revision: 1.2 $ - $Date: 2005/10/10 17:01:12 $
  26.  */
  27. public class DataModelToComboBoxModelAdapter extends
  28.         DataModelToListModelAdapter implements ComboBoxModel {
  29.     private Object selectedItem;
  30.     
  31.     public DataModelToComboBoxModelAdapter(TabularDataModel model, String fieldName) {
  32.         super(model, fieldName);
  33.     }
  34.     public void setSelectedItem(Object anItem) {
  35.         Object oldSelected = getSelectedItem();
  36.         this.selectedItem = anItem;
  37.         fireContentsChanged(this, -1, -1);
  38.         
  39.     }
  40.     public Object getSelectedItem() {
  41.         return selectedItem;
  42.     }
  43.     
  44. }