Results 1 to 1 of 1
Thread: Path for applets
- 02-23-2011, 01:18 AM #1
Senior Member
- Join Date
- Feb 2011
- Posts
- 107
- Rep Power
- 0
Path for applets
Hi!
I have converted a Java applet into an app and it works perfectly.
My problem, the .wav files have to be in the /bin folder
when I try to change it to any other folder (for example doing something like this: System.getProperty("user.dir")+"\\someDir\\example .wav")
it throws a null pointer exception (I think because it's taking methods from Applet and thus is limited by the restrictions put on Applet) .
Is there anyway to change the directory?
Here's my code:As you can see from the above, A.wav plays from the Bin directory... I would like it to play from theJava Code:import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.JLabel; public class GameSounds extends Panel implements ActionListener{ //// ******* SOUND FILES GO IN THE BIN FOLDER ********* /////// public GameSounds() {add(new JLabel("Hello"));} AudioClip one; public void init()// Init needed as it uses Applet methods { one = getAudioClip("A.wav"); } public AudioClip getAudioClip(String filename) {return Applet.newAudioClip(getClass().getResource(filename)); } public void A() { one.play();} public void actionPerformed(ActionEvent ae){} }
System.getProperty("user.dir")+"\\someDir\\";
directory.
Similar Threads
-
Applets
By rdjava in forum Advanced JavaReplies: 2Last Post: 01-27-2011, 12:07 AM -
New to Applets
By Psyclone in forum Java AppletsReplies: 8Last Post: 02-28-2010, 04:00 AM -
setting class-path & Library Path in ubantu
By programmer_007 in forum EclipseReplies: 18Last Post: 02-22-2010, 12:31 PM -
I need help with Applets
By ProgrammingPup in forum Advanced JavaReplies: 1Last Post: 12-22-2009, 08:07 PM -
Applets and dll
By peiceonly in forum Java AppletsReplies: 1Last Post: 04-01-2007, 10:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks