001: /*
002: * Copyright (c) 2004 JETA Software, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without modification,
005: * are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JETA Software nor the names of its contributors may
015: * be used to endorse or promote products derived from this software without
016: * specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023: * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026: * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: package com.jeta.forms.components.label;
031:
032: import java.awt.Image;
033: import java.beans.BeanDescriptor;
034: import java.beans.BeanInfo;
035: import java.beans.EventSetDescriptor;
036: import java.beans.Introspector;
037: import java.beans.MethodDescriptor;
038: import java.beans.PropertyDescriptor;
039: import java.util.ArrayList;
040:
041: import javax.swing.JLabel;
042:
043: /**
044: * The BeanInfo for JETALabel.
045: *
046: * @author Jeff Tassin
047: */
048: public class JETALabelBeanInfo implements BeanInfo {
049: private PropertyDescriptor[] m_props = null;
050:
051: /**
052: * ctor
053: */
054: public JETALabelBeanInfo() {
055: try {
056: ArrayList props = new ArrayList();
057: BeanInfo info = Introspector.getBeanInfo(JLabel.class);
058: PropertyDescriptor[] pds = info.getPropertyDescriptors();
059: for (int index = 0; index < pds.length; index++) {
060: PropertyDescriptor pd = pds[index];
061: if ("font".equals(pd.getName()))
062: pd.setPreferred(true);
063:
064: props.add(pd);
065: }
066:
067: PropertyDescriptor aa = new PropertyDescriptor(
068: "antiAliased", JETALabel.class, "isAntiAliased",
069: "setAntiAliased");
070: aa.setPreferred(true);
071: props.add(aa);
072: m_props = (PropertyDescriptor[]) props
073: .toArray(new PropertyDescriptor[0]);
074: } catch (Exception e) {
075: m_props = new PropertyDescriptor[0];
076: e.printStackTrace();
077: }
078: }
079:
080: public BeanInfo[] getAdditionalBeanInfo() {
081: return new BeanInfo[0];
082: }
083:
084: public BeanDescriptor getBeanDescriptor() {
085: return new BeanDescriptor(JETALabel.class);
086: }
087:
088: public int getDefaultEventIndex() {
089: return 0;
090: }
091:
092: public int getDefaultPropertyIndex() {
093: return 0;
094: }
095:
096: public EventSetDescriptor[] getEventSetDescriptors() {
097: return new EventSetDescriptor[0];
098: }
099:
100: public Image getIcon(int i) {
101: return null;
102: }
103:
104: public MethodDescriptor[] getMethodDescriptors() {
105: return new MethodDescriptor[0];
106: }
107:
108: /**
109: * @return a collection of JETAPropertyDescriptor objects
110: */
111: public PropertyDescriptor[] getPropertyDescriptors() {
112: return m_props;
113: }
114:
115: }
|