/*
	A basic extension of the java.applet.Applet class
 */

import java.awt.*;
import java.applet.*;

import cootank;
public class test_ck12 extends Applet
{
	public void init()
	{
		
	
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setLayout(null);
		setSize(570,415);
		setBackground(new Color(12632256));
		label3 = new java.awt.Label("before you delete or talk, you have to select an object.");
		label3.setBounds(60,324,324,18);
		add(label3);
		label4 = new java.awt.Label("Object (Don't click at it otherwise you will open a link.");
		label4.setBounds(60,360,324,16);
		add(label4);
		textField1 = new java.awt.TextField();
		textField1.setBounds(72,384,156,20);
		add(textField1);
		label1 = new java.awt.Label("To select an object, you need to move mouse cursor on the");
		label1.setBounds(60,343,324,16);
		add(label1);
		choice1 = new java.awt.Choice();
		choice1.addItem("Shell");
		choice1.addItem("Fish");
		choice1.addItem("Horse");
		choice1.addItem("Jelly");
		try {
			choice1.select(1);
		}
		catch (IllegalArgumentException e) { }
		add(choice1);
		choice1.setBounds(492,324,72,21);
		buttonAdd = new java.awt.Button();
		buttonAdd.setLabel("Add A");
		buttonAdd.setBounds(408,324,72,20);
		buttonAdd.setBackground(new Color(12632256));
		add(buttonAdd);
		buttonClear = new java.awt.Button();
		buttonClear.setLabel("Clear All Objects");
		buttonClear.setBounds(408,384,110,20);
		buttonClear.setBackground(new Color(12632256));
		add(buttonClear);
		buttonDel = new java.awt.Button();
		buttonDel.setLabel("Delete Sel Object");
		buttonDel.setBounds(408,360,108,20);
		buttonDel.setBackground(new Color(12632256));
		add(buttonDel);
		label5 = new java.awt.Label("Note:");
		label5.setBounds(12,319,48,17);
		label5.setFont(new Font("Dialog", Font.BOLD, 13));
		add(label5);
		label6 = new java.awt.Label("URL:");
		label6.setBounds(243,384,31,22);
		add(label6);
		textURL = new java.awt.TextField();
		textURL.setBounds(276,384,108,20);
		add(textURL);
		buttonTalk = new java.awt.Button();
		buttonTalk.setLabel("Text to talk");
		buttonTalk.setBounds(10,384,62,22);
		buttonTalk.setBackground(new Color(12632256));
		add(buttonTalk);
		//}}
	
		//{{REGISTER_LISTENERS
		SymAction lSymAction = new SymAction();
		textField1.addActionListener(lSymAction);
		buttonAdd.addActionListener(lSymAction);
		buttonClear.addActionListener(lSymAction);
		buttonDel.addActionListener(lSymAction);
		buttonTalk.addActionListener(lSymAction);
		//}}
	}
	
	//{{DECLARE_CONTROLS
	java.awt.Label label3;
	java.awt.Label label4;
	java.awt.TextField textField1;
	java.awt.Label label1;
	java.awt.Choice choice1;
	java.awt.Button buttonAdd;
	java.awt.Button buttonClear;
	java.awt.Button buttonDel;
	java.awt.Label label5;
	java.awt.Label label6;
	java.awt.TextField textURL;
	java.awt.Button buttonTalk;
	//}}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == textField1)
				textField1_EnterHit(event);
			else if (object == buttonAdd)
				buttonAdd_ActionPerformed(event);
			else if (object == buttonClear)
				buttonClear_ActionPerformed(event);
			else if (object == buttonDel)
				buttonDel_ActionPerformed(event);
			else if (object == buttonTalk)
				buttonTalk_ActionPerformed(event);
		}
	}

	void textField1_EnterHit(java.awt.event.ActionEvent event)
	{
		int r = cootank1.talk(-1, textField1.getText(), textURL.getText());		
		
	}

	void buttonAdd_ActionPerformed(java.awt.event.ActionEvent event)
	{
		cootank1.addObject(cootank1.IMG_SHELL+choice1.getSelectedIndex(), -1, "", "");
		 
	}

	void buttonClear_ActionPerformed(java.awt.event.ActionEvent event)
	{
		cootank1.deleteObject(-2);
		
	}

	void buttonDel_ActionPerformed(java.awt.event.ActionEvent event)
	{
		cootank1.deleteObject(-1);
		
	}

	void buttonTalk_ActionPerformed(java.awt.event.ActionEvent event)
	{
		textField1_EnterHit(null);
	}
}
