Path: blob/master/src/java.desktop/share/classes/java/beans/BeanInfo.java
41152 views
/*1* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans;2627import java.awt.Image;2829/**30* Use the {@code BeanInfo} interface31* to create a {@code BeanInfo} class32* and provide explicit information about the methods,33* properties, events, and other features of your beans.34* <p>35* When developing your bean, you can implement36* the bean features required for your application task37* omitting the rest of the {@code BeanInfo} features.38* They will be obtained through the automatic analysis39* by using the low-level reflection of the bean methods40* and applying standard design patterns.41* You have an opportunity to provide additional bean information42* through various descriptor classes.43* <p>44* See the {@link SimpleBeanInfo} class that is45* a convenient basic class for {@code BeanInfo} classes.46* You can override the methods and properties of47* the {@code SimpleBeanInfo} class to define specific information.48* <p>49* See also the {@link Introspector} class to learn more about bean behavior.50*51* @since 1.152*/53public interface BeanInfo {5455/**56* Returns the bean descriptor57* that provides overall information about the bean,58* such as its display name or its customizer.59*60* @return a {@link BeanDescriptor} object,61* or {@code null} if the information is to62* be obtained through the automatic analysis63*/64BeanDescriptor getBeanDescriptor();6566/**67* Returns the event descriptors of the bean68* that define the types of events fired by this bean.69*70* @return an array of {@link EventSetDescriptor} objects,71* or {@code null} if the information is to72* be obtained through the automatic analysis73*/74EventSetDescriptor[] getEventSetDescriptors();7576/**77* A bean may have a default event typically applied when this bean is used.78*79* @return index of the default event in the {@code EventSetDescriptor} array80* returned by the {@code getEventSetDescriptors} method,81* or -1 if there is no default event82*/83int getDefaultEventIndex();8485/**86* Returns descriptors for all properties of the bean.87* <p>88* If a property is indexed, then its entry in the result array89* belongs to the {@link IndexedPropertyDescriptor} subclass90* of the {@link PropertyDescriptor} class.91* A client of the {@code getPropertyDescriptors} method92* can use the {@code instanceof} operator to check93* whether a given {@code PropertyDescriptor}94* is an {@code IndexedPropertyDescriptor}.95*96* @return an array of {@code PropertyDescriptor} objects,97* or {@code null} if the information is to98* be obtained through the automatic analysis99*/100PropertyDescriptor[] getPropertyDescriptors();101102/**103* A bean may have a default property commonly updated when this bean is customized.104*105* @return index of the default property in the {@code PropertyDescriptor} array106* returned by the {@code getPropertyDescriptors} method,107* or -1 if there is no default property108*/109int getDefaultPropertyIndex();110111/**112* Returns the method descriptors of the bean113* that define the externally visible methods supported by this bean.114*115* @return an array of {@link MethodDescriptor} objects,116* or {@code null} if the information is to117* be obtained through the automatic analysis118*/119MethodDescriptor[] getMethodDescriptors();120121/**122* This method enables the current {@code BeanInfo} object123* to return an arbitrary collection of other {@code BeanInfo} objects124* that provide additional information about the current bean.125* <p>126* If there are conflicts or overlaps between the information127* provided by different {@code BeanInfo} objects,128* the current {@code BeanInfo} object takes priority129* over the additional {@code BeanInfo} objects.130* Array elements with higher indices take priority131* over the elements with lower indices.132*133* @return an array of {@code BeanInfo} objects,134* or {@code null} if there are no additional {@code BeanInfo} objects135*/136BeanInfo[] getAdditionalBeanInfo();137138/**139* Returns an image that can be used to represent the bean in toolboxes or toolbars.140* <p>141* There are four possible types of icons:142* 16 x 16 color, 32 x 32 color, 16 x 16 mono, and 32 x 32 mono.143* If you implement a bean so that it supports a single icon,144* it is recommended to use 16 x 16 color.145* Another recommendation is to set a transparent background for the icons.146*147* @param iconKind the kind of icon requested148* @return an image object representing the requested icon,149* or {@code null} if no suitable icon is available150*151* @see #ICON_COLOR_16x16152* @see #ICON_COLOR_32x32153* @see #ICON_MONO_16x16154* @see #ICON_MONO_32x32155*/156Image getIcon(int iconKind);157158/**159* Constant to indicate a 16 x 16 color icon.160*/161static final int ICON_COLOR_16x16 = 1;162163/**164* Constant to indicate a 32 x 32 color icon.165*/166static final int ICON_COLOR_32x32 = 2;167168/**169* Constant to indicate a 16 x 16 monochrome icon.170*/171static final int ICON_MONO_16x16 = 3;172173/**174* Constant to indicate a 32 x 32 monochrome icon.175*/176static final int ICON_MONO_32x32 = 4;177}178179180