Java Reference
In-Depth Information
public void actionPerformed(ActionEvent event)
public Dimension getPreferredSize()
//This is the method from which the
//application panel gets its sizeā€¦
return new Dimension(140,120);
Having created and compiled the above code, we may now need to package the
bean (and any required GIF fi les) within a JAR fi le, so that the bean may be loaded
into a particular IDE or transmitted easily across a network. (If this is not a require-
ment for you, then there is no need to do this.) JAR fi les are compressed by default,
using the same format as ZIP fi les. To do the packaging, we make use of Java's jar
utility. The syntax for executing this utility is:
jar <options> [<manifest>] <JAR_fi le> <fi le_list>
(Note that the order of parameters is not fi xed. In particular, the second and third
parameters may be reversed.)
The third parameter specifi es the name of the JAR fi le, which will normally have
the .jar extension. The fi nal parameter specifi es the fi les that are to go into this JAR
fi le. The second parameter specifi es the name of a manifest fi le that will hold infor-
mation about the contents of the JAR fi le. The manifest is normally a very short text
fi le. Though optional, it is good practice to include it, since it provides the user with
an easy way of fi nding out the contents of the JAR fi le without actually running the
associated JavaBean. At the very least, the manifest will have two lines specifying
a bean class fi le by naming the fi le (via property Name ) and stating explicitly (via
Boolean property Java-Bean ) that the fi le holds a JavaBean.
Name: beanPackage/MyBean.class
Java-Bean: True
Any other class fi les will also be listed, each separated from the preceding class
by a blank line.
Name: beanPackage/MyBean.class
Java-Bean: True
Name: SupportClass1.class
Name: SupportClass2.class
(We could also have further beans in the same JAR fi le.)
Search WWH ::

Custom Search