/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



/**
 *
 * @author dhafiq
 */
import  java.awt.Graphics;
import  java.io.IOException;
import  java.net.URL;
import  javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class URLSuara extends Frame {
       AudioInputStream suara;
       String eror1="Tidak Ada Eror";
       String eror2="Tidak Ada Eror";
       String eror3="Tidak Ada Eror";
       
       URLSuara(){
             URL url=this.getClass().getResource("desktop-login-ubuntu.WAV");
             try {
                   suara = AudioSystem.getAudioInputStream(url);
                   Clip klip =AudioSystem.getClip();
                   klip.open(suara);
                   klip.loop(0);
             } catch (UnsupportedAudioFileException e) {
                   eror1=e.toString();
             } catch (IOException e) {
                   eror2=e.toString();
             } catch (LineUnavailableException e) {
                   eror3=e.toString();
             }
        setTitle("Test URL Suara");
        setSize(250,200);
        setVisible(true);
        //setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        
        //untuk membuat action close program
         addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
  }
       
  public void paint(Graphics g){
        g.drawString("Eror 1 : "+eror1, 10, 50);
        g.drawString("Eror 2 : "+eror2, 10, 100);
        g.drawString("Eror 3 : "+eror3, 10, 150);
  }
  public static void main(String [] dhafiq){
        new URLSuara();
  }
}

