Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/data/swingbeaninfo/javax/swing/SwingBeanInfoBase.java
38892 views
/*1* Copyright (c) 1997, 2013, 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 javax.swing;2627import java.beans.*;28import java.lang.reflect.*;29import java.awt.Image;3031/**32* The superclass for all Swing BeanInfo classes. It provides33* default implementations of <code>getIcon</code> and34* <code>getDefaultPropertyIndex</code> as well as utility35* methods, like createPropertyDescriptor, for writing BeanInfo36* implementations. This classes is intended to be used along37* with <code>GenSwingBeanInfo</code> a BeanInfo class code generator.38*39* @see GenSwingBeanInfo40* @author Hans Muller41*/42public class SwingBeanInfoBase extends SimpleBeanInfo43{44/**45* The default index is always 0. In other words the first property46* listed in the getPropertyDescriptors() method is the one47* to show a (JFC builder) user in a situation where just a single48* property will be shown.49*/50public int getDefaultPropertyIndex() {51return 0;52}5354/**55* Returns a generic Swing icon, all icon "kinds" are supported.56* Subclasses should defer to this method when they don't have57* a particular beans icon kind.58*/59public Image getIcon(int kind) {60// PENDING(hmuller) need generic swing icon images.61return null;62}6364/**65* Returns the BeanInfo for the superclass of our bean, so that66* its PropertyDescriptors will be included.67*/68public BeanInfo[] getAdditionalBeanInfo() {69Class superClass = getBeanDescriptor().getBeanClass().getSuperclass();70BeanInfo superBeanInfo = null;71try {72superBeanInfo = Introspector.getBeanInfo(superClass);73} catch (IntrospectionException ie) {}74if (superBeanInfo != null) {75BeanInfo[] ret = new BeanInfo[1];76ret[0] = superBeanInfo;77return ret;78}79return null;80}81}828384