FaqFormCustomComponentIcon

How can I define an icon for my component in the palette?

It is very simple. You need to provide a BeanInfo class for your component and implement getIcon method. Here is a very simple example:

package com.me.beans;
public class MyComponentBeanInfo extends java.beans.SimpleBeanInfo {
    public java.awt.Image getIcon(int iconKind) {
        return loadImage("/com/me/beans/cool_icon.gif");
    }
}

Note: You need to follow the convention about naming the BeanInfo class: e.g. for bean class named MyComponent it is MyComponentBeanInfo. Both classes should be in the same package.


  Applies to: All NetBeans versions
  Platforms: All
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo