diff options
author | kcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-13 20:52:28 +0000 |
---|---|---|
committer | kcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-13 20:52:28 +0000 |
commit | d5ef5d8942c78d20a88d60f4e0defd5664d7cdcb (patch) | |
tree | 4fa6f6f1d3afa21552f08c070e8c73f6fc684a58 | |
parent | e91f424c2f3dd2619a6774551e5a84d040db02be (diff) |
Updated TextureImageNPOT to use getResources()
Made default file name a static final variable rather than a hard-coded string
-rw-r--r-- | src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java | 11 | ||||
-rw-r--r-- | src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java | 48 |
2 files changed, 27 insertions, 32 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java b/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java index 5ac421e..59cec91 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java +++ b/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java @@ -55,7 +55,8 @@ import javax.vecmath.*; import org.jdesktop.j3d.examples.Resources; public class TextureImage extends Applet { - + + private static final String defaultFileName = "resources/images/stone.jpg"; private java.net.URL texImage = null; private SimpleUniverse u = null; @@ -118,9 +119,9 @@ public class TextureImage extends Applet { public void init() { if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/stone.jpg"); + texImage = Resources.getResource(defaultFileName); if (texImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println(defaultFileName + " not found"); System.exit(1); } } @@ -161,9 +162,9 @@ public class TextureImage extends Applet { } } else { // the path to the image for an application - url = Resources.getResource("resources/images/stone.jpg"); + url = Resources.getResource(defaultFileName); if (url == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println(defaultFileName + " not found"); System.exit(1); } } diff --git a/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java index 6a08fe6..3976f0b 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java +++ b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java @@ -46,7 +46,6 @@ package org.jdesktop.j3d.examples.texture; import java.applet.Applet; import java.awt.*; -import java.awt.event.*; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.image.TextureLoader; @@ -54,9 +53,11 @@ import com.sun.j3d.utils.geometry.Box; import javax.media.j3d.*; import javax.vecmath.*; import java.util.Map; +import org.jdesktop.j3d.examples.Resources; public class TextureImageNPOT extends Applet { + private static final String defaultFileName = "resources/images/Java3d.jpg"; private java.net.URL texImage = null; private SimpleUniverse u = null; @@ -157,14 +158,11 @@ public class TextureImageNPOT extends Applet { public void init() { if (texImage == null) { // the path to the image for an applet - try { - texImage = new java.net.URL(getCodeBase().toString() + - "../images/Java3d.jpg"); - } - catch (java.net.MalformedURLException ex) { - System.out.println(ex.getMessage()); - System.exit(1); - } + texImage = Resources.getResource(defaultFileName); + if (texImage == null) { + System.err.println(defaultFileName + " not found"); + System.exit(1); + } } setLayout(new BorderLayout()); GraphicsConfiguration config = @@ -204,24 +202,20 @@ public class TextureImageNPOT extends Applet { public static void main(String[] args) { java.net.URL url = null; if (args.length > 0) { - try { - url = new java.net.URL("file:" + args[0]); - } - catch (java.net.MalformedURLException ex) { - System.out.println(ex.getMessage()); - System.exit(1); - } - } - else { - // the path to the image for an application - try { - url = new java.net.URL("file:../images/Java3d.jpg"); - } - catch (java.net.MalformedURLException ex) { - System.out.println(ex.getMessage()); - System.exit(1); - } - } + try { + url = new java.net.URL("file:" + args[0]); + } catch (java.net.MalformedURLException ex) { + System.out.println(ex.getMessage()); + System.exit(1); + } + } else { + // the path to the image for an application + url = Resources.getResource(defaultFileName); + if (url == null) { + System.err.println(defaultFileName + " not found"); + System.exit(1); + } + } new MainFrame(new TextureImageNPOT(url), 512, 512); } |