From e38b7787ddcc8d6fed61f7bc7a7f95bcbfe20ab8 Mon Sep 17 00:00:00 2001 From: David Gilbert Date: Thu, 9 Nov 2006 12:52:28 +0000 Subject: 2006-11-09 David Gilbert Fixes bug #29770 * java/beans/SimpleBeanInfo.java (loadImage): Check for nulls. --- java/beans/SimpleBeanInfo.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'java/beans') diff --git a/java/beans/SimpleBeanInfo.java b/java/beans/SimpleBeanInfo.java index cfb960484..56b1f7aa7 100644 --- a/java/beans/SimpleBeanInfo.java +++ b/java/beans/SimpleBeanInfo.java @@ -1,5 +1,5 @@ /* java.beans.SimpleBeanInfo - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package java.beans; import java.awt.Image; import java.awt.Toolkit; +import java.net.URL; /** ** SimpleBeanInfo is a class you may extend to more easily @@ -130,10 +131,16 @@ public class SimpleBeanInfo implements BeanInfo { ** and its BeanInfo are both loaded by the same ** ClassLoader, generally a reasonable assumption. ** @param location the URL relative - ** @return the Image in question. + ** @return the Image in question (possibly null). **/ - public Image loadImage(String location) { - return Toolkit.getDefaultToolkit().getImage(getClass().getResource(location)); + public Image loadImage(String location) + { + if (location == null) + return null; + URL url = getClass().getResource(location); + if (url == null) + return null; + return Toolkit.getDefaultToolkit().getImage(url); } } -- cgit v1.2.1