// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   ChoiceEditor.java

package lt.ktu.gmj.propertySheet;

import javax.swing.JComboBox;
import javax.swing.JComponent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;


// Referenced classes of package lt.ktu.gmj.propertySheet:
//			PropertyEditor, PropertyReader, PropertyWriter, InvalidPropertyException, 
//			PropertyNotifier, PropertyProvider

public class ChoiceEditor
	implements PropertyEditor
{

	private PropertyProvider provider;
	private JComboBox editor;

	public void refreshed()
	{
		int i = ((Integer)provider.get()).intValue();
		editor.setSelectedIndex(i);
	}

	public void fieldChanged()
	{
		try
		{
			int i = editor.getSelectedIndex();
			provider.set(new Integer(i));
		}
		catch(InvalidPropertyException invalidpropertyexception) { }
	}

	public JComponent component()
	{
		return (JComponent)editor;
	}

	public ChoiceEditor(PropertyProvider propertyprovider, String as[])
	{
		provider = null;
		editor = new JComboBox(as);
		editor.addItemListener(new ItemListener()
	{

		public void itemStateChanged(ItemEvent itemevent)
		{
			fieldChanged();
		}
		});
		provider = propertyprovider;
		provider.addObserver(this);
		refreshed();
	}

	

}
