Using Java beans to create components in your application

Source: Internet
Author: User
Tags object serialization
The JavaBeans module enables developers to create software units called components (that is, the beans that we know). You can load beans into more complex components, Java applets (applets), or applications. JavaBeans is widely used in IDE applications, making it easy for you to visualize composite components and dynamically modify their properties.

Beans is dynamic and allows you to change and customize it. In the design module in JavaBean Builder tool, you can visually customize and save (persistent) beans by using the Bean's Properties window. You can also select a bean from the toolbox, drag it to the form, modify its appearance and behavior with the interaction between defining it and other beans, and combine it with other beans into an applet or application, or a new bean.

Beans is widely used in function and use. For example, the following items are used for beans:

• Graphical user interface (GUI)

• Non-visual beans, such as spell checker

• Other types, such as applets

JavaBean specification

A javabean is actually a Java class. The JavaBeans API specification defines a simple specification for its methods and properties, and you must use these methods and attributes in Java classes, otherwise you cannot become a javabean. The bean's characteristics (i.e., properties, methods, events) should be discovered by the application with the bean, or discovered by the IDE application, such as IBM Eclispse or IntelliJ idea. This discovery process is called introspection (introspection).

Beans supports introspection in the following two ways (introspection):

They name features based on specific rules, known as design patterns. The Java.bean.Introspector class discovers Bean features by examining design patterns. The Java.beans.Introspector class relies on the core Java Reflection API.

They use an associated bean information class to explicitly provide properties, methods, and event information, which implements the BeanInfo interface, which can be explicitly supplied to the features that are used by the application Creation tool (Builder Tool).

Attributes are the characteristics of the bean's appearance and behavior, which you can modify at design time. The Bean Builder tool discovers its properties through introspection (introspection) and provides it for external processing. Beans provide properties for external operations, so they can be customized at design time. There are two ways to customize: One is by using the property editor, and the other by using a more powerful bean customizer.

Beans uses events to communicate with other beans. The bean that accepts the event (listens for beans) and the bean that activates the event (the source Bean) is contacted by registration. The Bean Builder tool detects a bean and determines which beans can activate the event (send) and which can handle the event (receive).

Persistence (persistence) ensures that beans can save and restore their state. After modifying the properties of a bean, you can save the state of the bean and revert to its unchanged state at a later time. The JavaBean architecture uses Java object serialization to support persistence. There is no difference between the Bean method and the Java method, and you can invoke these methods from other beans or a script environment. By default, all public methods are externally callable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.