63 |
class DummyAppletContext implements AppletContext |
class DummyAppletContext implements AppletContext |
64 |
{ |
{ |
65 |
private static final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_SET); |
private static final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_SET); |
|
private static final AudioClip DUMMY_CLIP = new DummyAudioClip(); |
|
66 |
|
|
67 |
DummyAppletContext() |
DummyAppletContext() |
68 |
{ |
{ |
79 |
*/ |
*/ |
80 |
public AudioClip getAudioClip(URL url) |
public AudioClip getAudioClip(URL url) |
81 |
{ |
{ |
82 |
try |
return Applet.newAudioClip(url); |
|
{ |
|
|
return (url.openConnection() != null ? DUMMY_CLIP : null); |
|
|
} |
|
|
catch (IOException ioe) |
|
|
{ |
|
|
return null; |
|
|
} |
|
83 |
} |
} |
84 |
|
|
85 |
/** Loads the <code>Image</code> instance by delegating to |
/** Loads the <code>Image</code> instance by delegating to |
162 |
{ |
{ |
163 |
return Collections.EMPTY_SET.iterator(); |
return Collections.EMPTY_SET.iterator(); |
164 |
} |
} |
|
|
|
|
/** Dummy <code>AudioClip</code> implementation that does nothing but |
|
|
* preventing <code>NullPointerException</code>S being thrown in programs |
|
|
* that expect a valid <code>AudioClip</code> instance to be returned by |
|
|
* their Applet. |
|
|
* |
|
|
* @author Robert Schuster |
|
|
*/ |
|
|
static class DummyAudioClip implements AudioClip |
|
|
{ |
|
|
public void play() |
|
|
{ |
|
|
} |
|
|
|
|
|
public void stop() |
|
|
{ |
|
|
} |
|
|
|
|
|
public void loop() |
|
|
{ |
|
|
} |
|
|
|
|
|
public String toString() |
|
|
{ |
|
|
return "DummyAudioClip never plays anything - implement javax.sound and make us happy :)"; |
|
|
} |
|
|
} |
|
165 |
} |
} |