Java Reference
In-Depth Information
computer screen. The full name of the class is javax.swing.JFrame . Here is
how we declare a variable of this class:
javax.swing.JFrame window;
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:
import javax.swing.JFrame;
we can declare a JFrame variable like this:
JFrame window;
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:
import javax.swing.*;
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:
http://java.sun.com/api/index.html
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).
a3
JFrame
JFrame()
getX()
JFrame(String)
getY()
show()
setLocation(int,int)
title
hide()
getTitle()
getHeight()
setTitle(String)
first Title
getWidth()
isResizable()
setSize(int,int)
setResizable(boolean)
toString()
window
a3
Figure 1.4:
An object of class javax.swing.JFrame
Search WWH ::




Custom Search