Saturday, 22 February 2014

EVENT CLASSES:The KeyEvent Class

KeyEvent and MouseEvent are subclasses of abstract InputEvent class .............


The KeyEvent class


                 A KeyEvent is gnerated when the keyboard input occurs.This low-level event is generated by a component object (such as a text field) when a key is pressed, released, or typed. The event is passed to every KeyListener or KeyAdapter object which registered to receive such events using the component's addKeyListener method.

Integer constants:


CHAR_UNDEFINED:
KEY_PRESSED and KEY_RELEASED events which do not map to a  valid Unicode character use this for the keyChar value.

KEY_FIRST:
               The first number in the range of ids used for key events.
KEY_LAST:
             The last number in the range of ids used for key events.

KEY_PRESSED:
          The "key pressed" event.

Friday, 21 February 2014

EVENT CLASSES:The ItemEvent Class

an item was selected or deselected....


ItemEvent class:

A semantic event which indicates that an item was selected or deselected.Defines the itemStateChanged() method when an item has been selected or deselected by the user. The event is passed to every ItemListener object which registered to receive such events using the component's addItemListener method.

The stateChange of any ItemEvent instance takes one of the following values:


  • DESELECTED:   The user deselected an item

           syntax:
             ItemEvent.DESELECTED


  • SELECTED: The user selected an item.

            syntax:
                 ItemEvent.SELECTED

Tuesday, 18 February 2014

THE HTML APPLET TAG

JAVA APPLET TAG IN HTML

The APPLET tag is used to start an applet from both an HTML document and from an applet viewer. An applet viewer will execute each APPLET tag that it finds in a separate window,while web browsers like Netscape Navigator, Internet Explorer, and Hot Java will allow many applets on a single page. So far, we have been using only a simplified form of the APPLET tag. 

The syntax for the standard APPLET tag is shown here. Bracketed items
are optional.

< APPLET
[CODEBASE = codebaseURL]
CODE = appletFile
[ALT = alternateText]
[NAME = appletInstanceName]
WIDTH = pixels HEIGHT = pixels
[ALIGN = alignment]
[VSPACE = pixels] [HSPACE = pixels]
>
[< PARAM NAME = AttributeName VALUE = AttributeValue>]
[< PARAM NAME = AttributeName2 VALUE = AttributeValue>]
. . .
[HTML Displayed in the absence of Java]

</APPLET>

Monday, 17 February 2014

APPLET FUNDAMENTALS IN JAVA

APPLET PROGRAMMING
How to Build a java applet...

An applet is a small Java program that is embedded and ran in some other Java interpreter program such as 

  •  a Java technology-enabled browser
  •  Sun’s applet viewer program called appletviewer
Applets do not use the main() method for initiating the execution of the code.Applets,when loaded,automatically call certain methods of Applet class to start and execute the applet code.
Applets cannot run any program from the local computer and they are restricted from using libraries from other languages such as C or C++.

INITIALIZATION AND TERMINATION OF APPLET IN JAVA

APPLET INITIALIZATION AND TERMINATION

When an applet begins, sequence of methods are:
1. init( )
2. start( )
3. paint( )
When an applet is terminated, the sequence is:
1. stop( )
2. destroy( )

init( ) :

  • The init( ) method is the first method to be called.
  •  Initializing the variables.
  •  This method is called only once during the run time of the applet.

AN APPLET SKELETON

Java:Applet Skeleton

Most of the applets override a set of methods that controls its execution.

  • Four of these methods init( ), start( ), stop( ), and destroy( ) are defined by Applet.
  • paint( ), is defined by the AWT Component class.


These five methods can be assembled into the skeleton shown here: