Results 1 to 4 of 4
  1. #1
    cocomojoe81 is offline Member
    Join Date
    Aug 2012
    Posts
    3
    Rep Power
    0

    Default Closing out of a wav file in a GUI

    Hello. I have created a GUI that plays a .wav file. Does anyone know of a simple command to close all files outside of a GUI or to simply reset the entire program to the beginning stage? Here is the code I use to run my song : public void songEngine(){
    try {

    File yourFile = new File(string);


    AudioFormat format;
    DataLine.Info info;
    Clip clip;

    stream = AudioSystem.getAudioInputStream(yourFile);

    format = stream.getFormat();
    info = new DataLine.Info(Clip.class, format);
    clip = (Clip) AudioSystem.getLine(info);
    clip.open(stream);
    clip.start();
    }
    catch (Exception e1) {
    //whatevers
    }

    }

    }
    The button used to stop is an Action listener. So I would need to implement that.

  2. #2
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Closing out of a wav file in a GUI

    Quote Originally Posted by cocomojoe81 View Post
    The button used to stop is an Action listener. So I would need to implement that.
    How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  3. #3
    cocomojoe81 is offline Member
    Join Date
    Aug 2012
    Posts
    3
    Rep Power
    0

    Default Re: Closing out of a wav file in a GUI

    I know how to do the Action Listener, I just don't know how to stop the file from playing.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: Closing out of a wav file in a GUI

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. closing Frame
    By twinkle in forum New To Java
    Replies: 3
    Last Post: 07-28-2012, 12:16 PM
  2. Closing a Port
    By dougie1809 in forum Networking
    Replies: 0
    Last Post: 02-19-2012, 02:56 AM
  3. Closing a clip
    By elamre in forum Java Applets
    Replies: 1
    Last Post: 02-01-2012, 11:43 AM
  4. Write to File After Closing
    By benn22 in forum New To Java
    Replies: 3
    Last Post: 04-12-2011, 11:54 PM
  5. Closing packages
    By uncopywritable in forum New To Java
    Replies: 0
    Last Post: 08-13-2007, 11:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •