Mouse Event Handling in Java

Mouse events are generated when the user clicks a mouse button or moves the mouse.Java provides two mouse events and two mouse events masks, so that programs can deal separately with ordinary mouse events(pressed, released, entered, and exited) and mouse-motion events(moved and dragged).

Applet contains a Simple Frame with a Label and a TextField

After the applet, the type of window, which is most often created, is derived from Frame. It is used to create child windows within applets, and top-level or child windows for application.

Program show the Time Elapsed in Seconds after the Start Button is Clicked

Start() method is used to start the execution and stop() method is used to stop the execution of the process. A process is a program that is executing.By using start and stop Button on a Frame the elapsed time display in the Label.

An applet program to draw different shapes

The drawLine, drawArc and drawPolygon methods in java.awt.Graphics are used to draw straight and curved lines. A Graphics object remembers a collection of setting for drawing images(using lines ,rectangle, ovals) and text, such as the currently selected font or the current color. All drawing(using geometrical figures) in Java must go through a Graphics object.

Using Fonts and Color in Applet

To display text, you must first select a font. A font is specified by its name, such as “Arial”, the style(plain, bold, italic, or bold italics), and the point size. Font, is an object in Java, so we need to create it via a call to new before we can use it.The setColor methods call selects a Colour that is used for all subsequent drawing operations.

Page 3 of 8