Components
Most modern interfaces are built around
the concept of "components" which are reusable widgets that
perform some user-interface function. You should be extremely
familiar with the ideas of components though if you have worked
on any computers since the mid-80s. Common components include
Buttons, Scroll Bars, Menu Bars, etc which are all basic to the
GUIs you use every day.
The JDK comes with a fairly diverse set
of components already built in which you can easily use by
working with the online documentation.
These components all derive from the
abstract base class java.awt.Component. By abstract, I mean
that you would never instantiate a Component object. instead,
you would extend the Component class in order to build a
functional component. The Component class is more of a
"generic" Component which contains al of the methods which all
components should have.
|
Perhaps an example will help clear up the
whole abstract class issue. You can think of a mammal as an
abstract class and a dog as an extended class from mammal. It
is easy to see that you can instantiate a dog object and
it should be easy to see that you cannot instantiate a mammal
object. After all, there is not animal which is "just" a
mammal. You can only have a "type" of mammal.
|
Specifically, the Component class
defines such things as alignment, background and foreground
colors, fonts, size and positioning etc. You should consult the
online documentation for the entire list of methods and fields
however, we will try to demonstrate most of the important ones
in the examples to follow.
Let's take a look at some of the most
often used components provided by the JDK.
NEXT
Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena currently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|