computer screen. The full name of the class is javax.swing.JFrame . Here is
how we declare a variable of this class:
Including the long package name can get pretty awkward. Working with
classes from package javax.swing.text.html.parser , for example, is cum-
bersome! Java provides a way to shorten this; the import statement allows us to
dispense with the package name and use only the class name.
If we use this import statement:
we can declare a JFrame variable like this:
Frequently, we want to use many classes from a package. Rather than write a
separate import statement for each class, we can use the wildcard character, “ * ”
to refer to all classes in the package:
Finding specifications of classes and methods in them
To use a class such as javax.swing.JFrame , you have to know what meth-
ods appear in the folders and what those methods do. The descriptions (or spec-
ifications ) of all the predefined packages, classes, and methods are collectively
called the Application Programming Interface , or API . The specifications tell
you what the classes are for and what their methods do.
The latest version of the Java API specifications can be found on the world
wide web at this url:
Appendix II explains how to use the API specs. You will access this site often
during your course on Java (and throughout your career as a Java programmer).
An object of class javax.swing.JFrame