JellyBeanBeanInfo.java Color-Annotated Source


This example (JellyBeanBeanInfo.java) illustrates how make a Bean's custom icon appear in toolboxes. JellyBean.java illustrates constrained and bound properties.

Icons may be 16x16 color, 32x32 color, 16x16 mono, or 32x32 mono. If a Bean is to support only one icon, it should support 16x16 color.



package sunw.demo.jelly; 

import java.beans.*;

public class JellyBeanBeanInfo extends SimpleBeanInfo {

    public java.awt.Image getIcon(int iconKind) {
	if (iconKind == BeanInfo.ICON_COLOR_16x16) {
	    java.awt.Image img = loadImage("JellyBeanIconColor16.gif");
	    return img;
	}
	if (iconKind == BeanInfo.ICON_COLOR_32x32) {
	    java.awt.Image img = loadImage("JellyBeanIconColor32.gif");
	    return img;
	}
	if (iconKind == BeanInfo.ICON_MONO_16x16) {
	    java.awt.Image img = loadImage("JellyBeanIconMono16.gif");
	    return img;
	}
	if (iconKind == BeanInfo.ICON_MONO_32x32) {
	    java.awt.Image img = loadImage("JellyBeanIconMono32.gif");
	    return img;
	}
	return null;
    }

}

Java, JavaBeans, and JavaSoft are trademarks of Sun Microsystems Inc.

Copyright © 1996 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043-1100 USA.
All rights reserved.