/*
 * PukeGUI.java
 *
 * Created on 7. april 2004, 14:40
 */

package GUI;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import Sound.*;
/**
 *
 * @author  Christian Arnesen
 */
public class PukeGUI extends JFrame {
    

    private JButton btnA;
    private JButton btnGen;
    private JButton btnOE;
    private JLabel jLabel1;
    private JButton btnClear;
    private JButton btnO;
    private JButton btnY;
    private JButton btnE;
    private JSeparator jSeparator1;
    private JButton btnU;
    private JButton btnARING;
    private JButton btnAE;
    private JTextField txtPuke;
    private JButton btnI;

    
    /** Creates new form PukeGUI */
    public PukeGUI() {
        super("PukeSound maker - Just add vocals!");
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        txtPuke = new JTextField();
        btnGen = new JButton();
        jLabel1 = new JLabel();
        jSeparator1 = new JSeparator();
        btnA = new JButton();
        btnE = new JButton();
        btnY = new JButton();
        btnU = new JButton();
        btnI = new JButton();
        btnO = new JButton();
        btnAE = new JButton();
        btnOE = new JButton();
        btnARING = new JButton();
        btnClear = new JButton();

        getContentPane().setLayout(null);

        txtPuke.setEditable(false);
        getContentPane().add(txtPuke);
        txtPuke.setBounds(10, 20, 390, 30);

        btnGen.setText("Generate sound!");
        btnGen.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               char[] tegn = txtPuke.getText().toCharArray();
               
               for(int i=0;i< tegn.length;i++){
                    
                   switch(tegn[i]){
                       case 'A':
                           SoundPlayer.spillA();
                           break;
                       case 'E':
                           SoundPlayer.spillE();
                           break;
                       case 'Y':
                           SoundPlayer.spillY();
                           break;
                       case 'U':
                           SoundPlayer.spillU();
                           break;
                       case 'I':
                           SoundPlayer.spillI();
                           break;
                       case 'O':
                           SoundPlayer.spillO();
                           break;
                       case 'Æ':
                           SoundPlayer.spillAE();
                           break;
                       case 'Ø':
                           SoundPlayer.spillOE();
                           break;
                       case 'Å':
                           SoundPlayer.spillARING();
                           break;
                   }  
                   try{
                    this.wait(5);
                   }catch(Exception e){
                   }
               }
            }
        });
        
        getContentPane().add(btnGen);
        btnGen.setBounds(20, 60, 130, 30);

        jLabel1.setFont(new java.awt.Font("Dialog", 1, 18));
        jLabel1.setText("Add vocals to the puke!");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(70, 110, 230, 30);

        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(10, 140, 390, 10);

        btnA.setText("A");
        btnA.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"A");
            }
        });

        getContentPane().add(btnA);
        btnA.setBounds(30, 160, 50, 26);
        
        btnE.setText("E");
        btnE.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"E");
            }
        });
        getContentPane().add(btnE);
        btnE.setBounds(30, 190, 50, 26);

        btnY.setText("Y");
        btnY.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"Y");
            }
        });
        getContentPane().add(btnY);
        btnY.setBounds(90, 160, 50, 26);

        btnU.setText("U");
        btnU.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"U");
            }
        });
        getContentPane().add(btnU);
        btnU.setBounds(90, 190, 50, 26);

        btnI.setText("I");
        btnI.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"I");
            }
        });
        getContentPane().add(btnI);
        btnI.setBounds(150, 160, 50, 26);

        btnO.setText("O");
        btnO.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"O");
            }
        });
        getContentPane().add(btnO);
        btnO.setBounds(150, 190, 50, 26);

        btnAE.setText("\u00c6");
        btnAE.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"Æ");
            }
        });

        getContentPane().add(btnAE);
        btnAE.setBounds(210, 160, 50, 26);

        btnOE.setText("\u00d8");
        btnOE.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"Ø");
            }
        });
        getContentPane().add(btnOE);
        btnOE.setBounds(210, 190, 50, 26);

        btnARING.setText("\u00c5");
        btnARING.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText(txtPuke.getText()+"Å");
            }
        });
        getContentPane().add(btnARING);
        btnARING.setBounds(270, 160, 50, 26);

        btnClear.setText("Clear");
        btnClear.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               txtPuke.setText("");
            }
        });
        getContentPane().add(btnClear);
        btnClear.setBounds(260, 60, 90, 26);
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(false);
        setSize(420,275);
        setLocation(Toolkit.getDefaultToolkit().getScreenSize().width/2 - 420, Toolkit.getDefaultToolkit().getScreenSize().height/2 -275);
        setVisible(true);
        
    }


   
  
    public static void main(String args[]) {
        new PukeGUI();
    }
    
    
    
    
}

