Java 1.2.x Basics (Java Software Developers Kit 1.2.x)
I. Java keywords abstract boolean break byte case catch char class const (reserved, but not used) continue default do double else extends false final finally float for goto (reserved, but not used) if implements import (makes available without full qualification, but does not include actual text like C++ does) instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try void volatile while II. Java primitive data types (p. 105) boolean byte char double float int long short III. Java key concepts action event action listener application applet bytecode class component event driven (Java) vs. object driven (C++) vs. function driven (C) event handling gui html interface layout manager member access modifiers (public, private, protected) method object package register run-time exceptions run-time interpreter threads IV. Java components (classes in the java.awt inheritance hierarchy) (pp. 515, 565) java.lang.object java.util.EventObject java.awt.AWTEvent ActionEvent AdjustmentEvent ItemEvent ComponentEvent ContainerEvent FocusEvent PaintEvent WindowEvent InputEvent KeyEvent MouseEvent java.awt.Color black ( 0, 0, 0) red (255, 0, 0) green ( 0, 255, 0) blue ( 0, 0, 255) yellow (255, 255, 0) white (255, 255, 255) gray (128, 128, 128) light gray (192, 192, 192) dark gray ( 64, 64, 64) java.awt.Component paint() repaint() Label (these heavyweight components are tied directly to the local platform's GUI capabilities TextField for their "look and feel") TextArea Button CheckBox ComboBox List Panel java.awt.Container -- a collection of related comonents Box javax.swing.JComponent JLabel (these lightweight components are NOT tied directly to the local platform's GUI JTextField capabilities for their "look and feel") JTextArea JPassWord JButton JCheckBox JComboBox JList JPanel java.awt.Font PLAIN BOLD ITALIC Serif Monospaced Sans-Serif java.awt.FontMetrics ascent descent leading height java.awt.Graphics drawLine(int x1, int y1, int x2, int y2) drawRect(int x, int y, int width, int height) fillRect(int x, int y, int width, int height) clearRect(int x, int y, int width, int height) drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) fillRoundRect(int x, int y, int widht, int height, int arcWidth,int arcHeight) draw3DRect(int x, int y, int width, int height, boolean b) fill3DRect(int x, int y, int width, int height, boolean b) drawOval(int x, int y, int width, int height) fillOval(int x, int y, int width, int height) java.awt.Graphics2D Ellipse2D.Float Ellipse2D.Double Rectangle2D.Float Rectangle2D.Double RoundRectangle2D.Float RoundRectangle2D.Double Arc2D.Float Arc2D.Double Line2D.Float Line2D.Double java.awt.Polygon drawPolygon(...) fillPolygon(...) Polycon() Polygon(...) java.awt.BasicStroke java.awt.GradientPaint java.awt.TexturePaint java.awt.geom.GeneralPath java.awt.geom.Line2D java.awt.geom.RectangularShape java.awt.geom.Arc2D java.awt.geom.Ellipse2D java.awt.geom.Rectangle2D java.awt.geom.RoundRectangle2D java.awt.Paint java.awt.Shape java.awt.Stroke V. Processing an event 1. Implement the appropriate interface 2. Declare the component reference 3. Allocate the component reference 4 Register an event handler for that component 5 Implement an event hander (override the required function from the interface) VI. Methods of the Applet class that are called by the appletviewer or browser (p. 247) 1. public void init() -- initialize variables -- initialize GUI components 2. public void start() -- called after init() is finished -- called every time the browser returns to the HTML page on which the applet resides, after browsing another HTML page 3. public void paint(Graphics g) -- called after init() is finished and start() has begun executing, to draw on the applet using the Graphics object 'g' -- called automatically every time the applet needs to be repainted 4. public void stop() -- called when the browser user leaves the HTML page on which the applet resides -- called when the browser is closed -- stops execution of animations, threads, etc., as required to suspend the applet's execution 5. public void destroy() -- called when the browser is closed (when the applet is removed from memory) -- performs tasks required to free resources allocated to the applet, such as terminating threads


This page was last updated on 05.30.2000.