JDK's Dt.jar and Java BeanInfo interfaces

Source: Internet
Author: User
Tags tools and utilities

Below the java_home/lib there are two more important jar files, Tools.jar and Dt.jar.

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

Search Dt.jar on Oracle's official website to find the JDK and JRE File structure page, as follows

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

Like a Passage

/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. including 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 enable developers to customize their applications.

There are two points in the Dt.jar explanation:

1. Design time (Designtime) is the runtime (runtime) object, the simple point is that a program is written, a 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. Take a closer look, 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 out 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 specific implementation of a bean, if he wants to provide explicit information about the bean, he can 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 explicit information. You can choose the information you want to provide, and the rest of the information will be obtained through the low-level reflection bean class method and the application of the standard design pattern automatic analysis.

You have the opportunity to provide a lot of different information as part of the Xyzdescriptor class. But you don't have to panic, you just need to provide the minimal core information required by each construction method.

More image information can be viewed in several getter methods of the BeanInfo interface. The JDK also provides a simple implementation of the Simplebeaninfo class, BeanInfo interface. You can simply look at it.

As mentioned above, Tools.jar and Dt.jar are used for development tools. Let's take 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, note 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]
IDE estimates are basically the way it is used.







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.