JDK's Dt.jar and Java BeanInfo interfaces

Source: Internet
Author: User
Tags tools and utilities

There are two more important jar files below the java_home/lib. Tools.jar and Dt.jar.

Tools.jar a brief introduction to the last article. Here to introduce the next Dt.jar.

Search Dt.jar at Oracle's official site to find the JDK and JRE File structure This page, such as the following

Https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/jdkfiles.html

There are a few words like the following

/jdk1.7.0/lib
Files used by the development tools. Includes tools.jar, which contains non-core classes for support of the tools and utilities in the JDK. Also includes dt.jar, the Designtime archive of BeanInfo files that tell interactive development environments (IDE's) How to display the Java Developer customize them for a application translation:

/jdk1.7.0/lib

The files used by the development tool. Contains Tools.jar and Dt.jar. Tools.jar contains non-core classes that support the various tools in the JDK. Also included Dt.jar,dt.jar is the archive of design-time beaninfo files that tell the interactive development environment How to display Java components and how to let developers define their own applications.

There are two points in the Dt.jar explanation:

1. Design time (Designtime) is the runtime object. The simple point is that it is a time to hit the code, one is the time to run the program.

2.BeanInfo file on this beaninfo file, we can open a Dt.jar file and look at it.


It's really all xxxbeaninfo classes. Look more carefully. The previous XXX are all swing price groups.

First find out what the next beaninfo is doing.

Find BeanInfo on Oracle's website. Find the following page and find that BeanInfo is an interface,

Https://docs.oracle.com/javase/7/docs/api/java/beans/BeanInfo.html

First look at what Doc says, here is the Java Doc translation of the BeanInfo interface,

public interface BeanInfo

A detailed implementation of a bean, false assumptions provide clear information about the bean. He was able to provide a beaninfo class that implements the BeanInfo interface to provide clear information about the bean's methods, properties, events, and so on.

A bean's implementation does not need to provide a complete set of clear information.

You can choose the information you want to provide, and the rest of the information will be obtained through a low-level reflection bean class approach and the application of the standard design pattern to its own initiative analysis.

You have the opportunity to provide very different information as part of the Xyzdescriptor class. But you don't have to panic, in fact you just need to provide the minimum amount of core information required by each construction method.

More image information is able to look at several getter methods of the BeanInfo interface.

The JDK also provides a simple implementation of the Simplebeaninfo class, BeanInfo interface. It's easy to see.

As mentioned above, Tools.jar and Dt.jar are used for development tools. Here's a look at how this set of APIs is used.

First write a MyClass class

Package Com.highgo.test.beaninfo;public class MyClass {private string Field1;public string GetField1 () {return field1;} public void SetField1 (String field1) {this.field1 = field1;}}
In writing a Myclassbeaninfo class. Notice the naming of this class, Myclass+beaninfo

Package Com.highgo.test.beaninfo;import Java.awt.image;import Java.beans.beandescriptor;import java.beans.BeanInfo ; import Java.beans.eventsetdescriptor;import Java.beans.methoddescriptor;import java.beans.PropertyDescriptor; public class Myclassbeaninfo implements beaninfo{@Overridepublic BeanDescriptor getbeandescriptor () {//TODO Auto-generated method Stubbeandescriptor bd = new BeanDescriptor (myclass.class); Bd.setname ("MyName"); Bd.setdisplayname ("Mydisplayname"); Bd.setshortdescription ("Hi, My first BeanInfo test!"); return BD;} @Overridepublic eventsetdescriptor[] Geteventsetdescriptors () {//TODO auto-generated method Stubreturn New EVENTSETDESCRIPTOR[0];} @Overridepublic int Getdefaulteventindex () {//TODO auto-generated method Stubreturn 0;} @Overridepublic propertydescriptor[] Getpropertydescriptors () {//TODO auto-generated method Stubreturn New PROPERTYDESCRIPTOR[0];} @Overridepublic int Getdefaultpropertyindex () {//TODO auto-generated method Stubreturn 0;} @Overridepublic MethoddesCriptor[] Getmethoddescriptors () {//TODO auto-generated method Stubreturn new methoddescriptor[0];} @Overridepublic beaninfo[] Getadditionalbeaninfo () {//TODO auto-generated method Stubreturn new beaninfo[0];} @Overridepublic Image geticon (int iconkind) {//TODO auto-generated method Stubreturn null;}}

Test it.

Import Com.highgo.test.beaninfo.myclass;public class Test{public static void Main (string[] args) throws introspectionexception {BeanInfo Bi2 = Introspector.getbeaninfo (Myclass.class); System.out.println (Bi2.getbeandescriptor ());}}

Control Desk

Java.beans.beandescriptor[name=myname; displayname=mydisplayname; Shortdescription=hi, My first BeanInfo Test!; Beanclass=class Com.highgo.test.beaninfo.MyClass]
The IDE is expected to be basically that way.







Dt.jar and Java BeanInfo interfaces for JDK

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.