import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.applet.*;
import java.io.File;
import java.net.MalformedURLException;
import javax.swing.ImageIcon;
import javax.swing.Icon;
import java.net.URL;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit [url=http://www.cloudgarden.com]Cloud Garden (Java Resources)[/url] for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Beta extends javax.swing.JApplet {
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JButton jButton1;
	private JTextField jTextField1;
	private JList jList1;
	
	String tier[]=new String[15];
	
	File f;
	AudioClip sound=null;
	/**
	* Auto-generated main method to display this 
	* JApplet inside a new JFrame.
	*/
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				Beta inst = new Beta();
				frame.getContentPane().add(inst);
				((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
				frame.pack();
				frame.setVisible(true);
				frame.setResizable(false); 
			}
		});
	}
	
	public Beta() {
		super();
		
		
		tier[0] = "Giraffe";
	    tier[1] = "Affe";             // richtige Antwort
	    tier[2] = "Eule";
	     
	    tier[3] = "Löwe";           // richtige Antwort
	    tier[4] = "Vogel";
	    tier[5] = "Katze";
	     
	    tier[6] = "Maus";
	    tier[7] = "Stier";
	    tier[8] = "Hund";          // richtige Antwort
	    
	    tier[9] = "Adler";
	    tier[10] = "Bär";         // richtige Antwort
	    tier[11] = "Antilope";
	    
	    tier[12] = "Papagei";
	    tier[13] = "Zebra";
	    tier[14] = "Wolf";        // richtige Antwort
	    initGUI();
	     f = new File("ton1.wav");
		
		
	}
	
	private void initGUI() {
		try {
			this.setSize(952, 588);
			getContentPane().setLayout(null);
			{
				ListModel jList1Model = 
					new DefaultComboBoxModel(
							new String[] { tier[0], tier[1], tier[2] });
				jList1 = new JList();
				getContentPane().add(jList1);
				jList1.setModel(jList1Model);
				jList1.setBounds(436, 371, 129, 57);
				jList1.addListSelectionListener(new ListSelectionListener() {
					public void valueChanged(ListSelectionEvent evt) {
						jList1ValueChanged(evt);
					}
				});
				jList1.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						
					}
				});
			}
			{
				jTextField1 = new JTextField();
				getContentPane().add(jTextField1);
				jTextField1.setBounds(310, 477, 416, 21);
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1);
				jButton1.setBounds(451, 192, 80, 75);
				jButton1.setOpaque(false);
				jButton1.setContentAreaFilled(false);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButton1ActionPerformed(evt);
					}
				});
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setIcon(new ImageIcon(getClass().getClassLoader().getResource("ed.png")));
				jLabel3.setBounds(243, 285, 475, 80);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("ko4.png")));
				jLabel2.setBounds(337, 44, 294, 286);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Jungle-stock1113.jpg")));
				jLabel1.setBounds(-954, -390, 1920, 1080);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	AudioClip ton;
	private void jButton1ActionPerformed(ActionEvent evt) {
		System.out.println("jButton1.actionPerformed, event="+evt);
		//TODO add your code for jButton1.actionPerformed
		
	
		try{
			sound = Applet.newAudioClip( f.toURL() );
		} catch (MalformedURLException e ) {
			e.printStackTrace();
		}
		sound.play();
		
		
		
	}
			  
	private void jList1ValueChanged(ListSelectionEvent evt) {
		System.out.println("jList1.valueChanged, event="+evt);
		//TODO add your code for jList1.valueChanged
		
		String auswahl=(String) jList1.getSelectedValue();
		jTextField1.setText(auswahl);
		
		if(auswahl.equals(tier[1]) ){
			jTextField1.setText("Deine Antwort ist richtig.");
			
			ListModel jList1Model = 
				new DefaultComboBoxModel(
						new String[] { tier[3], tier[4], tier[5] });
			jList1.setModel(jList1Model);
			
		
		}else
		{
			jTextField1.setText("Das ist leider falsch");
	
		}
		
	}