Tuesday, October 5, 2010

Write a bean class criteria (2)


Then, if broadcast events from the bean class, it must listen for events to track the object. To do this, you need to define the listener instance variables and addListener and removeListener methods. Back Fireworks.java source, for example, you will see that:

private Vector listeners = new Vector ();

.

.

.

public void addFireworksListener (FireworksListener f)

(

listeners.addElement (f);

)

public void removeFireworksListener (FireworksListener f)

(

listeners.removeElement (f);

)

Finally, bean class needs to correct the actual number will broadcast the event to all listeners. To do this, you need to define the processEvent method and call it the appropriate number of times, for example:

public void processFireworksEvent (FireworksEvent e)

(

for (Enumeration enum = listeners.elements (); enum.hasMoreElements ();)

((FireworksListener) enum.nextElement ()). Exploded (e);

)

public void run ()

(

.

.

.

processFireworksEvent (new FireworksEvent (this, FireworksEvent.EXPLODED));

)

Tips and tricks

If you want to create a product class Bean, please remember do first eight things:

So that the smaller the bean the better, but pay attention to whether the current browser support small bean

bean may lead to tools for delay, and then cause the browser to lag, leading to delayed JDK itself. If you have Shiyong cutting edge class, or The nature of bean bean large, you should Kaolv you the bean as a plug-in, and in a self-contained jar in Fasong it, or Ruyoukeneng, giving it its own in Small installation process. You will lose some of the advantages of a small bean:

Web administrators must be more than one step: to remind users to browse Web pages must be downloaded and installed before you install the program jar or

Web surfers must also be more than one step: before browsing the Web page to download and install your jar or installer.

Can be translated to your bean

Translation of all text, including bean name and a brief description of its characteristics, divided into. Properties file. JAR wizard will do this for you.

You need to remember two things and yourself are: characteristics of editors and customizers. Custom device, the dialog box select the features editor or features editor all the terms, such as high, medium and low, must be separated for the translations. Ideally, you can actually translate bean and Bean in the jar to provide a variety of languages. Properties file. However, if you provide at least the local language. Properties file, then third-party translation for your bean.

In the list of documents for the bean specified Depends-On: tag

The Bean's jar all the files marked as "run-time needs vs. Only in the editing needs." In the run-time needs of all the files listed in the jar manifest file will be dependent on: After the label. JAR wizard release tag to make this operation very simple and allows you access to the right of the list of files.

If you do not specify depends on: tags, tool will assume that all documents are required at run time. This download performance (such as unnecessary to download the editor and other features only required in editing the paper) is very good.

Gives you a clear choice for the size of bean

bean will achieve getPreferredSize method to use when the first structure may be defined keyword feature, it's good. If in the first place when, bean is 0 x 0 pixels, the user may be confused. When the change keyword features, the preferred size should work. For example, if the bean has a vertical and horizontal directions between the conversion feature, the preferred size should be written in order to adjust itself.

Specify the default properties for the bean

Using JavaBean specification part of the default properties, it will make your bean in some tools easy to use. JAR wizard to make this operation easier and you get the BeanInfo for the right.

Specified for the bean and the characteristics of a brief non-technical name and a brief description

Looking for a brief non-technical name in place of lengthy technical jargon. For example, instead of using sum interval accumulatorInterval. Please also note that features were expressed preference to lower-case characters and words in the spaces between the leaves, it will be more for the user-friendly.

Narrow the scope of the user visible features

To provide a clear bean BeanInfo for each instance variable does not appear as bean properties, and do not show each method of operation for the Bean. JAR wizard to make this operation easier and you get the BeanInfo for the right.

For the bean specified large icons and small icons

Finally, Bean offers a large (32x32) and small (16x16) color icon. Moreover, to ensure that the icon has a different gray transparent background. Although rarely used, you should develop to provide the customary black and white icon. JAR wizard palette tab to make this operation easier, and make you get the BeanInfo.






Recommended links:



Hart governance "disease" HEWLETT-PACKARD



Lists Dictionaries Education



CMMB TD and who needs who more?



comparison Food And Drink



DivX TO iPod



If tomorrow is the last night of IPv4



TS to MKV



PS7.0 landscape plan to add a rain effect



3GP To WMV



how in the oracle database to run os Commands



FIVE Tips for promotion



Deep Antivirus Guide (1)



Wang Haibo: Society world partners, with 10 000 win



Simple Telephony



No comments:

Post a Comment