Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/beans/BeanInfo.java
38829 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*/51public interface BeanInfo {5253/**54* Returns the bean descriptor55* that provides overall information about the bean,56* such as its display name or its customizer.57*58* @return a {@link BeanDescriptor} object,59* or {@code null} if the information is to60* be obtained through the automatic analysis61*/62BeanDescriptor getBeanDescriptor();6364/**65* Returns the event descriptors of the bean66* that define the types of events fired by this bean.67*68* @return an array of {@link EventSetDescriptor} objects,69* or {@code null} if the information is to70* be obtained through the automatic analysis71*/72EventSetDescriptor[] getEventSetDescriptors();7374/**75* A bean may have a default event typically applied when this bean is used.76*77* @return index of the default event in the {@code EventSetDescriptor} array78* returned by the {@code getEventSetDescriptors} method,79* or -1 if there is no default event80*/81int getDefaultEventIndex();8283/**84* Returns descriptors for all properties of the bean.85* <p>86* If a property is indexed, then its entry in the result array87* belongs to the {@link IndexedPropertyDescriptor} subclass88* of the {@link PropertyDescriptor} class.89* A client of the {@code getPropertyDescriptors} method90* can use the {@code instanceof} operator to check91* whether a given {@code PropertyDescriptor}92* is an {@code IndexedPropertyDescriptor}.93*94* @return an array of {@code PropertyDescriptor} objects,95* or {@code null} if the information is to96* be obtained through the automatic analysis97*/98PropertyDescriptor[] getPropertyDescriptors();99100/**101* A bean may have a default property commonly updated when this bean is customized.102*103* @return index of the default property in the {@code PropertyDescriptor} array104* returned by the {@code getPropertyDescriptors} method,105* or -1 if there is no default property106*/107int getDefaultPropertyIndex();108109/**110* Returns the method descriptors of the bean111* that define the externally visible methods supported by this bean.112*113* @return an array of {@link MethodDescriptor} objects,114* or {@code null} if the information is to115* be obtained through the automatic analysis116*/117MethodDescriptor[] getMethodDescriptors();118119/**120* This method enables the current {@code BeanInfo} object121* to return an arbitrary collection of other {@code BeanInfo} objects122* that provide additional information about the current bean.123* <p>124* If there are conflicts or overlaps between the information125* provided by different {@code BeanInfo} objects,126* the current {@code BeanInfo} object takes priority127* over the additional {@code BeanInfo} objects.128* Array elements with higher indices take priority129* over the elements with lower indices.130*131* @return an array of {@code BeanInfo} objects,132* or {@code null} if there are no additional {@code BeanInfo} objects133*/134BeanInfo[] getAdditionalBeanInfo();135136/**137* Returns an image that can be used to represent the bean in toolboxes or toolbars.138* <p>139* There are four possible types of icons:140* 16 x 16 color, 32 x 32 color, 16 x 16 mono, and 32 x 32 mono.141* If you implement a bean so that it supports a single icon,142* it is recommended to use 16 x 16 color.143* Another recommendation is to set a transparent background for the icons.144*145* @param iconKind the kind of icon requested146* @return an image object representing the requested icon,147* or {@code null} if no suitable icon is available148*149* @see #ICON_COLOR_16x16150* @see #ICON_COLOR_32x32151* @see #ICON_MONO_16x16152* @see #ICON_MONO_32x32153*/154Image getIcon(int iconKind);155156/**157* Constant to indicate a 16 x 16 color icon.158*/159final static int ICON_COLOR_16x16 = 1;160161/**162* Constant to indicate a 32 x 32 color icon.163*/164final static int ICON_COLOR_32x32 = 2;165166/**167* Constant to indicate a 16 x 16 monochrome icon.168*/169final static int ICON_MONO_16x16 = 3;170171/**172* Constant to indicate a 32 x 32 monochrome icon.173*/174final static int ICON_MONO_32x32 = 4;175}176177178