diff options
| author | Jonas Kvarnström <jonas.kvarnstrom@liu.se> | 2021-01-16 14:47:59 +0100 |
|---|---|---|
| committer | Jonas Kvarnström <jonas.kvarnstrom@liu.se> | 2021-01-16 14:47:59 +0100 |
| commit | 95a58a87579950c08230d3713e7d0251774821a7 (patch) | |
| tree | 423109b494d9200728d7e353e7988383587477fc /src | |
| parent | a530dc7011597128102355ddc9d18cf8b21826e3 (diff) | |
| download | tdde30-95a58a87579950c08230d3713e7d0251774821a7.tar.gz | |
Added comment to resource reader
Diffstat (limited to 'src')
| -rw-r--r-- | src/se/liu/tddd78/examples/ResourceTester.java | 6 |
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); |
