summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Kvarnström <jonas.kvarnstrom@liu.se>2021-01-16 14:47:59 +0100
committerJonas Kvarnström <jonas.kvarnstrom@liu.se>2021-01-16 14:47:59 +0100
commit95a58a87579950c08230d3713e7d0251774821a7 (patch)
tree423109b494d9200728d7e353e7988383587477fc
parenta530dc7011597128102355ddc9d18cf8b21826e3 (diff)
downloadtdde30-95a58a87579950c08230d3713e7d0251774821a7.tar.gz
Added comment to resource reader
-rw-r--r--src/se/liu/tddd78/examples/ResourceTester.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/se/liu/tddd78/examples/ResourceTester.java b/src/se/liu/tddd78/examples/ResourceTester.java
index d18a3e6..9898293 100644
--- a/src/se/liu/tddd78/examples/ResourceTester.java
+++ b/src/se/liu/tddd78/examples/ResourceTester.java
@@ -52,6 +52,12 @@ public class ResourceTester
// Like above, we need to access the image through a resource.
final URL image = ClassLoader.getSystemResource("images/hello_world.png");
+ // If the image does not exist, image will be null, and a NullPointerException
+ // will be thrown when the ImageIcon is created below. This is OK in this
+ // very specific case, because each *resource* is an integral part of the
+ // program. It cannot be missing unless the project is damaged,
+ // in which case all bets are off in any case.
+
// The ImageIcon class can read an entire image directly from any URL.
ImageIcon icon = new ImageIcon(image);