à®®ேலுà®®் பல புதிய டெக்னாலஜி பற்à®±ி தெà®°ிந்து கொள்ள, எங்கள் "டெக் டுப் தமிà®´் நாடு" யூட் டூஃப் சேனலை SUBSCRIBE செய்து கொள்ளவுà®®்.

Breaking

Sunday, 8 October 2017

JAVA GUI 2


JAVA GUI 2

Event Handling

Any program that uses GUI (graphical user interface) such as Java application written for windows, is event driven. Event describes the change of state of any object. Example : Pressing a button, Entering a character in Textbox.

Components of Event Handling

Event handling has three main components,

1. Events : An event is a change of state of an object.

2. Events Source : Event source is an object that generates an event.

3. Listeners : A listener is an object that listens to the event. A listener gets notified when an event occurs.

How Events are handled ??

A source generates an Event and send it to one or more listeners registered with the source. Once event is received by the listener, they process the event and then return. Events are supported by a number of Java packages, like java.util, java.awt and java.awt.event.

Important Event Classe and Interface

Event Classe Description Listener Interface
ActionEventgenerated when button is pressed, menu-item is selected, list-item is double clicked.ActionListener
MouseEventgenerated when mouse is dragged, moved,clicked,pressed or released also when the enters or exit a component.MouseListener
KeyEventgenerated when input is received from keyboard.KeyListener
ItemEventgenerated when check-box or list item is clicked.ItemListener
TextEventgenerated when value of textarea or textfield is changed.TextListener
MouseWheelEventgenerated when mouse wheel is moved.MouseWheelListener
WindowEventgenerated when window is activated, deactivated, deiconified, iconified, opened or closed.WindowListener
ComponentEventgenerated when component is hidden, moved, resized or set visible.ComponentEventListener
ContainerEventgenerated when component is added or removed from container.ContainerListener
AdjustmentEventgenerated when scroll bar is manipulated.AdjustmentListener
FocusEventgenerated when component gains or loses keyboard focus.FocusListener

 

Example of Event Handling

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;

public class Test extends Applet implements KeyListener
{
 String msg="";
 public void init()
 {
   addKeyListener(this);       
 }
 public void keyPressed(KeyEvent k)
 {
   showStatus("KeyPressed");
 }
 public void keyReleased(KeyEvent k)
 {
   showStatus("KeyRealesed");
 }
 public void keyTyped(KeyEvent k)
 {
   msg = msg+k.getKeyChar();
   repaint();
 }
 public void paint(Graphics g)
 {
   g.drawString(msg, 20, 40);
 }
}

HTML code :
< applet code="Test" width=300, height=100 >

No comments:

Post a Comment

Hai , Post your comment . (required, Bugs, Errors )

You need to see


SUBSCRIBE NOW



Backlinks : Website Design Company in Coimbatore
Website Design Company in Tamil nadu
Website Design Company in Karur
Website Design Company in Erode
Website Design Company in ooty
Website Design Company in theni
Website Design Company in thoothukudi
Website Design Company in Chennai
Website Design Company in Sathy
Website Design Company in Coimbatore Tamilnadu
Cheap Website Design Company in Coimbatore
Adsense Website Design Company in Coimbatore
ecommerce Website Design Company in Coimbatore
school Website Design Company in Coimbatore
Academy Website Design Company in Coimbatore
Test Website Design Company in Coimbatore
Best Website Design Company in Coimbatore
Adsense Website Design Company in Coimbatore
Adsense Website Design Company in Tamil nadu
Adsense Website Design Company in Karur
Adsense Website Design Company in Erode
Adsense Website Design Company in ooty
Adsense Website Design Company in theni
Adsense Website Design Company in thoothukudi
Adsense Website Design Company in Chennai
Adsense Website Design Company in Sathy
Free SEO Tools online
Free SEO Tools online Website
Free SEO Tools online Plagiarism
Free SEO Tools online article rewriter tool
Free SEO Tools online article reading and writing criticism
Free SEO Tools online seo backlink
Free SEO Tools online Free backlink maker
Free SEO Tools online seo backlink strategy
Free SEO Tools online content writting
360 help SEO Tools online Plagiarism checker
360 help SEO Tools online seo backlink
360 help SEO Tools online Free backlink maker
360 help SEO Tools online content writting
360 help SEO Tools online article rewriter tool
360 help SEO Tools
360 help SEO Tools India
360 help SEO Tools Tamil
360 help SEO Tools website