001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: KListModelComboBoxAdapter.java,v $ 023 Revision 1.2 2004/05/31 07:30:26 markl 024 Final cleanup and bugfixes of kiwi.ui.model. 025 026 Revision 1.1 2004/05/13 21:40:21 markl 027 new classes 028 029 ---------------------------------------------------------------------------- 030*/ 031 032package kiwi.ui.model; 033 034import java.util.*; 035import javax.swing.*; 036import javax.swing.event.*; 037 038import kiwi.event.*; 039import kiwi.ui.*; 040 041/** A model adapter that allows a <code>KListModel</code> to be used with a 042 * Swing <code>JComboBox</code> component. This adapter wraps a 043 * <code>KListModel</code> implementation and exposes a 044 * <code>ComboBoxModel</code> interface, and translates the corresponding 045 * model events. 046 * 047 * @author Mark Lindner 048 * @since Kiwi 2.0 049 */ 050 051public class KListModelComboBoxAdapter extends KListModelListAdapter 052 implements ComboBoxModel 053 { 054 private Object selectedItem = null; 055 056 /** Construct a new <code>KListModelComboBoxAdapter</code> for the given 057 * <code>JComboBox</code>. 058 * 059 * @param jcombobox The <code>JComboBox</code> that will be used with this 060 * adapter. 061 */ 062 063 public KListModelComboBoxAdapter(JComboBox jcombobox) 064 { 065 super(); 066 jcombobox.setRenderer(renderer); 067 } 068 069 /* implementation of ComboBoxModel */ 070 071 /* 072 */ 073 074 public Object getSelectedItem() 075 { 076 return(selectedItem); 077 } 078 079 /* 080 */ 081 082 public void setSelectedItem(Object item) 083 { 084 selectedItem = item; 085 } 086 087 } 088 089/* end of source file */