Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

BeanInfo get info from Bean

Posted on 2007-11-15
2
Medium Priority
?
217 Views
Last Modified: 2012-06-27
Hi.
I'm working on a java bean with a beanInfo.
I've pasted my two classes below.
ParentNode contains the info, and ParentNodeBean contains display information.
Now I'd like to change my BeanDescriptor.DisplayName to ParentNode.getMyName
But I can not figure out how?
Enyone?


public class ParentNodeBeanInfo extends SimpleBeanInfo {
    private final static Class parentNode = ParentNode.class;
 
    @Override
    public Image getIcon(int type) {
       return Utilities.loadImage("/nodeTest/suite.png");
    }
    
    
  @Override
  public BeanDescriptor getBeanDescriptor() {
      BeanDescriptor beanDescriptor = new BeanDescriptor(parentNode);
    beanDescriptor.setDisplayName("Test name");
  //  bd.setDisplayName(parentNode.getTestName()); //<--this is it
    return beanDescriptor;
  }
}
 
public class ParentNode implements Serializable {
 
    private String myName;
    private String testValue;
    private PropertyChangeSupport propertySupport;
 
    public ParentNode() {
        propertySupport = new PropertyChangeSupport(this);
    }
 
    public String getMyName() {
        return myName;
    }
 
    public void setMyName(String myName) {
        String old = this.myName;
        this.myName = myName;
        propertySupport.firePropertyChange("myName", old, this.myName);
    }
 
    public String getTestValue() {
        return testValue;
    }
 
    public void setTestValue(String testValue) {
        this.testValue = testValue;
    }
 
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
 
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    
    @Override
    public String toString() {
        return "getMyName:" + this.getMyName();
    }

Open in new window

0
Comment
Question by:kristian_gr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 5

Expert Comment

by:deeppra
ID: 20288161
But the BeanDescriptor.DisplayName display a gendral information about the bean its not for representing the bean values
0
 
LVL 5

Accepted Solution

by:
deeppra earned 2000 total points
ID: 20288164
For more info
http://www.research.ibm.com/able/doc/reference/com/ibm/able/doc-files/AbleBeanInfo.html
http://javadude.com/articles/javabeanattributes.html



As explained earlier JBuilder discovers the properties, methods and events of a bean through introspection based on the JavaBeans API. If we want to provide more information about a bean, or want to refine the information available through introspection, we should define a class that implement the BeanInfo interface. A BeanInfo class typically subclasses the SimpleBeanInfo class, that is a no-op implementation of the BeanInfo interface. When we want to override only one or two methods in the BeanInfo interface it is easier to subclass SimpleBeanInfo then to implement BeanInfo directly. In order for JBuilder to be able to find the corresponding BeanInfo class to a bean, there is a naming convention to be followed: a BeanInfo class should have the same name as the bean with the string BeanInfo appended.

A BeanInfo class specifies a number of pieces of information for our bean:

    * Icons that represent the bean.
    * A BeanDescriptor object that contains a reference to a Customizer class for the bean. Customizers will be explained later.
    * A list of supported properties of the bean, along with a short description of these properties. These description will be used by JBuilder as tool tips in the Object Inspector.
    * Reference to property editor classes. Property editors will be explained later.
    * A list of methods supported by the bean, again with short descriptions of each one.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question