aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/org/jdesktop/j3d/examples/appearance
diff options
context:
space:
mode:
authorjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-02-14 19:26:20 +0000
committerjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-02-14 19:26:20 +0000
commitdb51908057c333598179879522a230fc4929aeb3 (patch)
treef17cfb6d4fe7445280ff49f57e4b2337dc9a6a09 /src/classes/org/jdesktop/j3d/examples/appearance
parent39d071c598f993a69999ec06cdff6e38cb5448c0 (diff)
Modified programs to access data files via Resources class
Diffstat (limited to 'src/classes/org/jdesktop/j3d/examples/appearance')
-rw-r--r--src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java61
-rw-r--r--src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java61
2 files changed, 59 insertions, 63 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java
index 578401e..bed5d0b 100644
--- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java
+++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java
@@ -46,14 +46,13 @@ package org.jdesktop.j3d.examples.appearance;
import java.applet.Applet;
import java.awt.*;
-import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.image.TextureLoader;
-import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;
+import org.jdesktop.j3d.examples.Resources;
public class AppearanceMixed extends Applet {
@@ -443,28 +442,23 @@ public class AppearanceMixed extends Applet {
public void init() {
if (bgImage == null) {
// the path to the image for an applet
- try {
- bgImage = new java.net.URL(getCodeBase().toString() +
- "../images/bg.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
-
+ bgImage = Resources.getResource("resources/images/bg.jpg");
+ if (bgImage == null) {
+ System.err.println("resources/images/bg.jpg not found");
+ System.exit(1);
+ }
+ }
+
if (texImage == null) {
- // the path to the image for an applet
- try {
- texImage = new java.net.URL(getCodeBase().toString() +
- "../images/apimage.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
- setLayout(new BorderLayout());
+ // the path to the image for an applet
+ texImage = Resources.getResource("resources/images/apimage.jpg");
+ if (texImage == null) {
+ System.err.println("resources/images/apimage.jpg not found");
+ System.exit(1);
+ }
+ }
+
+ setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
@@ -495,14 +489,17 @@ public class AppearanceMixed extends Applet {
// the path to the image file for an application
java.net.URL bgurl = null;
java.net.URL texurl = null;
- try {
- bgurl = new java.net.URL("file:../images/bg.jpg");
- texurl = new java.net.URL("file:../images/apimage.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- new MainFrame(new AppearanceMixed(bgurl, texurl), 700, 700);
+ bgurl = Resources.getResource("resources/images/bg.jpg");
+ if (bgurl == null) {
+ System.err.println("resources/images/bg.jpg not found");
+ System.exit(1);
+ }
+ texurl = Resources.getResource("resources/images/apimage.jpg");
+ if (texurl == null) {
+ System.err.println("resources/images/apimage.jpg not found");
+ System.exit(1);
+ }
+
+ new MainFrame(new AppearanceMixed(bgurl, texurl), 700, 700);
}
}
diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java
index 8d57c48..03f25d8 100644
--- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java
+++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java
@@ -46,12 +46,12 @@ package org.jdesktop.j3d.examples.appearance;
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;
import javax.media.j3d.*;
import javax.vecmath.*;
+import org.jdesktop.j3d.examples.Resources;
public class AppearanceTest extends Applet {
@@ -316,28 +316,23 @@ public class AppearanceTest extends Applet {
public void init() {
if (bgImage == null) {
- // the path to the image for an applet
- try {
- bgImage = new java.net.URL(getCodeBase().toString() +
- "../images/bg.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
-
+ // the path to the image for an applet
+ bgImage = Resources.getResource("resources/images/bg.jpg");
+ if (bgImage == null) {
+ System.err.println("resources/images/bg.jpg not found");
+ System.exit(1);
+ }
+ }
+
if (texImage == null) {
- // the path to the image for an applet
- try {
- texImage = new java.net.URL(getCodeBase().toString() +
- "../images/apimage.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- }
+ // the path to the image for an applet
+ texImage = Resources.getResource("resources/images/apimage.jpg");
+ if (texImage == null) {
+ System.err.println("resources/images/apimage.jpg not found");
+ System.exit(1);
+ }
+ }
+
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
@@ -369,14 +364,18 @@ public class AppearanceTest extends Applet {
// the path to the image file for an application
java.net.URL bgurl = null;
java.net.URL texurl = null;
- try {
- bgurl = new java.net.URL("file:../images/bg.jpg");
- texurl = new java.net.URL("file:../images/apimage.jpg");
- }
- catch (java.net.MalformedURLException ex) {
- System.out.println(ex.getMessage());
- System.exit(1);
- }
- new MainFrame(new AppearanceTest(bgurl, texurl), 700, 700);
+
+ bgurl = Resources.getResource("resources/images/bg.jpg");
+ if (bgurl == null) {
+ System.err.println("resources/images/bg.jpg not found");
+ System.exit(1);
+ }
+ texurl = Resources.getResource("resources/images/apimage.jpg");
+ if (texurl == null) {
+ System.err.println("resources/images/apimage.jpg not found");
+ System.exit(1);
+ }
+
+ new MainFrame(new AppearanceTest(bgurl, texurl), 700, 700);
}
}