-In Java, every class defines a new type (data type).
-The JComponent class provides the framework for building all kinds of user interface
components. Particular components—such as buttons, labels, and list boxes—are im‐
plemented as subclasses of JComponent
-JComponent is really the tip of another iceberg called Swing. Swing is Java’s user interface
toolkit
-Component is a subclass of the top-level Object class, so all these classes are types of
Object . Every other class in the Java API inherits behavior from Object , which defines
a few basic methods,
-The java. and javax. package hierarchies are special. Any package that begins with
java. is part of the core Java API and is available on any platform that supports Java.
The javax. package normally denotes a standard extension to the core platform, which
may or may not be installed.
-There are many different event classes, including MouseEvent , KeyEvent , and
ActionEvent .
-GUI components in Java generate events for specific kinds of user actions. For example,
if you click the mouse inside a component, the component generates a mouse event.
Objects can ask to receive the events from one or more components by registering a
listener with the event source.
-The mouseDragged() method is
called automatically on a listener to receive the events generated when the user drags
the mouse—that is, moves the mouse with any button pressed. The mouseMoved()
method is called whenever the user moves the mouse over the area without pressing a
button.
-Because we changed the coordinates for the message (when we dragged the mouse), we
would like HelloComponent2 to redraw itself. We do this by calling repaint() , which
asks the system to redraw the screen at a later time.
-an interface is a list of methods that the class must have
-Interfaces
give us a way of acting on objects based on their capabilities without knowing or caring
about their actual type.
-A class in Java can
extend only one class, but can implement as many interfaces as it wants;
-Component is a base class from which all of Java’s GUI components are derived. It contains
variables that represent the location, shape, general appearance, and status of the object
as well as methods for basic painting and event handling.
-The Container causes its children to be displayed
and arranges them on the screen according to a particular layout strategy
- A LayoutManager object embodies a partic‐
ular scheme for arranging components on the screen and adjusting their sizes.