90
APPLET Applet Component Layout Manager Event Handling Adapter Class

Applet

Embed Size (px)

Citation preview

Page 1: Applet

APPLET

•Applet Component •Layout Manager•Event Handling• Adapter Class

Page 2: Applet

Applet Component

COMPONENT

Container Labels Button CheckBox CheckBoxGroup Choice Lists ScrollBar TextField TextArea MenuBar Dialog Boxes FileDialog

Page 3: Applet

Applet Component

Label :- Constructor:- new Label( ) throws HeadLessException new Label(String str) throws HeadlessException new Label(String str,int how) throws HeadlessException how=Label.LEFT or Label.RIGHT or Label.CENTER

Methods:- void setText(String str) String getText();

void setAlignment(int how) int getAlignment();

Page 4: Applet

Applet Component

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ Label L1,L2; public void init() { L1=new Label(); L1.setText(“ABCD”); L2=new Label(); add(L1); add(L2); } }

Page 5: Applet

Applet Component

Button :-Constructor:- new Button() throws HeadlessException new Button(String str) throws

HeadlessException Methods:- void setLabel(String str); //label for

the buttons. String getLabel();

Page 6: Applet

Applet Componentimport java.awt.*;import java.applet.*;public class MyApp extends Applet{ Button b1,b2; public void init() { b1=new Button(); b1.setText(“PUSH”); L2=new Button(); add(b1); add(b2); } }

Page 7: Applet

Applet ComponentCheck BoxesConstructor :- new Checkbox()throws HeadlessException // blank checkbox unchecked new Checkbox(String )throws HeadlessException// create a named checkbox new Checkbox(String ,boolean ) throws HeadlessException

// create a named checkbox if true checkbox is checked othewise it is false

new Checkbox(String,boolean,CheckboxGroup) throws HeadlessException new Checkbox(String,CheckboxGroup,boolean) throws HeadlessException //create a named checkbox with initial stateeither true or false depend on

boolean value , and also declare that check box is a part of checkbox group or not. Method:- boolean getState(); void setState(String str); String getLabel(); void setLabel(String str);

Page 8: Applet

Applet Component

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ Checkbox c1,c2,c3; public void init() { c1=new Checkbox(); c2=new Checkbox(“WIN98”); c3=new Checkbox(WinXP,null,true); c1.setLabel(WIN95“); add(c1); add(c2); add(c3); } }

Page 9: Applet

Applet Component

CheckboxGroup:- radiobutton only one checkboc at a time .

Constructor:- new CheckboxGroup(); Method:-

Checkbox getSelectedCheckbox(); void setSelectedCheckbox(Checkbox which)

Page 10: Applet

Applet Component

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ Checkbox c1,c2,c3; public void init() { CheckboxGroup cbg=new CheckboxGroup(); c1=new Checkbox(WIN(%,cbg,true); c2=new Checkbox(“WIN98”,cbg,false); c3=new Checkbox(WinXP,cbg,false); c1.setLabel(WIN95“); add(c1); add(c2); add(c3); } }

Page 11: Applet

Applet Component

Choice Controls:- Popup list of item which the user may choose.Constructor :- new Choice();Methods:- void add(String name) String getSelectedItem();

int getSelectedIndex();// index start from 0. void select(int index); void select (String name) ; String getItem(int index) ;

Page 12: Applet

Applet Componentimport java.awt.*;import java.applet.*;public class MyApp extends Applet{ Choice c1; public void init() { Choice c1=new Choice(); c1.add(“WIN95”); c1.add(“WIN98”); c1.add(“WINXP”); add(c1); } }

Page 13: Applet

Applet Component

Lists :- Multiple choice scroll selection list. Constructor :-

new List();

new List(int numrows);

new List(int numrows,boolean multiselect)

Method:-

void add(String name);

void add(String name,int index); // index start from 0. index=-1 it means add the item at the end of the list.

String getSelectedItem(); // index of selected item.

int getSelectedIndex(); //index start from 0. if more then one item is selected or no selection is made -1 is returned.

String [ ] getSelectedItems() ;//names of selcted items

int [ ] getSelectedIndexes() ; //indexes of selected items.

Page 14: Applet

Applet Componentimport java.awt.*;

import java.applet.*;

public class MyApp extends Applet

{

List l1;

public void init()

{

l1=new List(5, true);

l1.add(“WIN95”);

l1.add(“WIN98”);

l1.add(“WINXP”);

l1.add(“WINVISTA”);

l1.add(“WIN&”);

add(l1);

}

}

Page 15: Applet

Applet Component

Scroll Bar :- Used to select continuous values between a specified minimum and maximum .

Constructor:-

new Scrollbar() // horiozontal scrollbar

new Scrollbar(int style) //style=Scrollbar.Horizontal

Scrollbar.Vertical

new Scrollbar(int style,int initialvalue,int

thumbsize,int min,int max);

//initialvalue of the scroolbar, thumbsize represent the no of represent by the height of the thumb . minimumn and maximum value of scrollbar is represented by min and max .

Page 16: Applet

Applet Component Scrollbar:- Methods :-

void setValues(int initval,int thumbsize,int max,int min); int getValue();// To retrieve the current value void setValue(int newvalue);// To set the new value of scrollbar. int getMinimum(); int getMaximum(); void setUnitIncrement(int newincr); void setBlockedIncrement(int newincr); // each time the 1 is incremented from the scroll bar each

time it is scrolled up or down one line. By default pageup and pagedown value are 10 we can change it by above two methods.

Page 17: Applet

Applet Component

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ Scrollbar hsb,vsb; public void init() { hsb=new Scrollbar(Scrollbar.Horizontal,0,1,0,50); vsb=new Scrollbar(Scrollbar.Vertical,0,1,0,50) add(hsb);

add(vsb); } }

Page 18: Applet

Applet ComponentTextField:-

Costructor:-

new TextField();

new TextField(int numchar);// create a textfield numchar wide

new TextField(String str); // create a text field with str.

new TextField(String str,int numchar); //create a textfield sets with str and numchar

set its width;

Methods:-

String getText();

void setText(String str);

String getSelectedText();

void select(int startindex,int endindex);//select at startindex and ending at endindex-1

void setEditable();

boolean isEditable();

Page 19: Applet

Applet Component

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ TextField t1; public void init() { t1=new TextField( ); add(t1); } }

Page 20: Applet

Applet ComponentTextField:-

Costructor:-

new TextArea();

new TextArea(int numline,int numchar);

new TextArea(String str);

new TextField(String str,int numline,int numchar);

new TextField(String str,int numline,int numchar,int sbars);// bars= SCROLLBARS_BOTH

SCROLLBARS_NONE

SCROLLBARS_HORIZONTAL_ONLY

SCROLLBARS_VERTICAL_ONLY

Methods:-

String getText();

void setText(String str);

String getSelectedText();

void select(int startindex,int endindex);//select at startindex and ending at endindex-1

void setEditable();

boolean isEditable();

Page 21: Applet

Applet Component

TextField:-Methods:- void append(String str); // append the string

specified by str void insert(String str,int index);//pass the

string str at specified by the index

void replaceRange(String str,int startind,int end ind); // replace the

characters from startindex to endIndex-1

Page 22: Applet

Applet Component( MenuBar,Menu,MenuItem)

Constructors:-MenuBar :- new MenuBar(); Menu:- new Menu();

new Menu(String optionname);

MenuItem:- new MenuItem();

new MenuItem(String str); new MenuItem( String str,MenuShortcut keyAccel);

Page 23: Applet

Applet Component( MenuBar,Menu,MenuItem)

Methods:- MenuItem:- Menuitem add(MenuItem

mi); MenuBar:- Menu add(Menu m);

Page 24: Applet

Applet Componentimport java.awt.*;

import java.applet.*;

public class MyApp extends Applet

{

MenuBar mb,Menu m1,m2, MenuItem mi1,mi2,mi3

public void init()

{

mb=new MenuBar();

m1=new Menu(“File”);

m2=new Menu(“Edit”);

mi1=new MenuItem(“New”);

mi2=new MenuItem(“Open”);

mi3=new MenuItem(“Cut”);

m1.add(mi1);

m1.add(mi2);

m2.add(mi3)

mb.add(m1);

mb.add(m2);

setMenuBar(mb);

add(t1);

}

}

Page 25: Applet

Applet Component

Container:-

1) Inherit the Component class . 2) It has additional method that allow other component object to be nested within it. 3)Container object contain other Container object. This makes multilevel containment system. 4)Conatianer is responsible for laying out(positioning) any component that it contain.It does this through the layout managers.

methods:- void add(Component cmp); void remove(Component cmp);

Page 26: Applet

Layout Manager Every Component that we place in the

Container has a size and location in Container.This size and location of the component in the Container is managed by the LayoutManager. Following are the types of LayoutManagers

FlowLayoutManager GridLayoutManager BorderLayoutManager CardLayoutManager

Page 27: Applet

Layout Manager

Methods:- void setLayout(LayoutManager

layoutobj); // layoutobj is the object of

LayoutManager class.if we pass null then we disable the layout manager and determine the shape and position manually using setBound() defined by Component class.

Page 28: Applet

Layout Manager

FlowLayoutManager :- new FlowLayout(); // maintain the space of 5 pixels between

each component. new FlowLayout(int how) // how specify

alignment of component how=FlowLayout.LEFT

FlowLayout.RIGHT FlowLayout.CENTER new FlowLayout(int how,int horz, int vert ) // horz & vert specify horizontal and vertical space left between

each component .

Page 29: Applet

Layout Manager

import java.awt.*;

import java.applet.*;public class MyApp extends Applet{ TextField t1,t2; Button b1,b2; FlowLayout fl; public void init() { fl=new FlowLayout(); setLayout(fl); t1=new TextField();

t1=new TextField(); b1=new Button(“add”); b2=new Button(“sustract”); add(t1);

add(t2); add(b1); add(b2);

} }

Page 30: Applet

Layout Manager

GridLayoutManager:- new GridLayoutManager( ); //create

a grid of single row and

single column .

new GridLayoutManager(int row, int col);

new GridLayoutManager(int row, int col,int horz,int col);

Page 31: Applet

Layout Manager

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ TextField t1,t2; Button b1,b2;

GridLayout gl; public void init() { gl=new GridLayout(2,2); setLayout(gl);; t1=new TextField();

t1=new TextField(); b1=new Button(“add”); b2=new Button(“sustract”); add(t1);

add(t2); add(b1); add(b2);

} }

Page 32: Applet

Layout Manager

BorderLayoutManager :- It has four narrow fixed width components at

the edges and one large area in the center ,The four sides is referred to as north, south,east,west and middle are is referred as center. BorderLayout reffers the following constant that specify the regions.

BorderLayout.CENTER BorderLayout.EAST BorderLayout.WEST BorderLayout.SOUTH BorderLayout.NORTH All the regions specify with the Component when we add

that component in that Container. void add(Component compobj , Object region);

Page 33: Applet

Layout Manager

Constructor:-

new BorderLayoutManager( );

new BorderLayout(int horz,int vert);

Page 34: Applet

Layout Manager

import java.awt.*;import java.applet.*;public class MyApp extends Applet{ TextField t1,t2; Button b1,b2,b3; BorderLayout bl; public void init() { bl=new BorderLayout( ; setLayout(bl);; t1=new TextField();

t1=new TextField(); b1=new Button(“add”);

Page 35: Applet

Layout Manager

b2=new Button(“sustract”); b3=new Button(“equal”) ; add(t1,BorderLayout.EAST);

add(t2, BorderLayout.WEST; add(b1, BorderLayout.SOUTH); add(b2, BorderLayout.NORTH);

add(b2, BorderLayout.CENTER); } }

Page 36: Applet

Event Handling

Event:- It can be generated as a

consequence of person interacting with the elements in a gui. Some of the activities that cause events to be generated are pressing a button ,entring a character via a keyboard , selecting a list etc.

“ In the Event Delegation model,an Event is an object that describes a state change in a source. ”

Page 37: Applet

Event Handling

To process the events we need to identify this events and then take some action. This is known as

event handling. The modern approach to handling an event is based on “Event Delegation Model”. In this model we have 3 following entities .

Source Event Handler or Listenr

Page 38: Applet

Event Handling

Event Delegation Model :- (Delegation Event Model) Source generates

EventsHandeled by

register

Handler

Page 39: Applet

Event Handling

Source :- Source is used to generate the event and it is mainly a Component.Examples Button,TextField etc. Every source and component has the predefined .

Event :- An Event can be generated by the source.It can possible that the same events are generated by different sources. Events are represented by classes .

Handler or Listener:- To handle the event handlers are used . Every event is a predefined handler. The event can be generated by any source but the handler is always be same. Handlers are represented by or interfaces.

Page 40: Applet

Event Handling

ActionEvent is an event is generated when we click on button ar press the enter key in TextField . And this ActionEvent is handled by ActionListener interface.

Button onclick ActionEvent handled by

ActionListener

on enter

TextField

Page 41: Applet

Event Handling

ActionListener is an interface which contains the following method.

public void actionPerformed(ActionEvent ae)

When the ActionEvent is generated the

ActionListener’s actionPerformed method get executed . The operation that we want to perform on the click of Button should be put within the actionPerformed method.

Page 42: Applet

Event Handling

For the event handling we need to create the handler class. The class will be handler class when it implement the appropriate listener and override the methods of interface.

Ex:- public class A implements ActionListener { public void actionPerformed(ActionEvent ae) { -------------- -------------- -------------- -------------- } }

Page 43: Applet

Event HandlingHandler 1:- public class A implements ActionListener { public void actionPerformed(ActionEvent ae) { -------------- -------------- -------------- -------------- } }Handler 2:-

public class B implements ActionListener { public void actionPerformed(ActionEvent ae) { -------------- -------------- -------------- -------------- } }

Page 44: Applet

Event Handling(ActionEvent) import java.awt.*; import java.applet.*; import java.awt.event.*; public class MyApp extends Applet { public TextField t1,t2,t3; Button b1; FlowLayout fl; public void init()

Page 45: Applet

Event Handling(ActionEvent) { fl=new FlowLayout( ); setLayout(fl); t1=new TextField(5); t2=new TextField(5); t3=new TextField(5); b1=new Button("add"); add(t1); add(t2); add(t3); add(b1);

Page 46: Applet

Event Handling(ActionEvent) AddHandler ah=new

AddHandler(t1,t2,t3); b1.addActionListener(ah); } }

Page 47: Applet

Event Handling(ActionEvent) import java.awt.*; import java.applet.*; import java.awt.event.*; public class AddHandler implements ActionListener { TextField th1,th2,th3; public AddHandler(TextField t33,TextField t43,TextField t53) { th1=t33; th2=t43; th3=t53; }

Page 48: Applet

Event Handling(ActionEvent) public void actionPerformed(ActionEvent ae) { int

i=Integer.parseInt(th1.getText()); int

j=Integer.parseInt(th2.getText()); String s1=i+j+ ""; th3.setText(s1); } }

Page 49: Applet

Event Handling

Once the handler is created it should be registered with source without which eventhandling is not possible it is necessary otherwise we don’t know which handler handle the event.

To register the handler with the source th methods are provided in the source.

Registration methods of Button and Textfield source is

following . void addActionListener(ActionListner al) // al represent the object of that class which implement

the ActionListener interface. Method belonging to Button and Textfield class.

Page 50: Applet

Event Handling

Action Event- 1)button is clicked. 2) list item is double

clicked. 3)menu item is selected. 4) txt field is entered. ActionListener :- public void actionPerformed(ActionEvent

ae)

Page 51: Applet

Event Handling

ItemEvent:- 1) checkbox or list item is selected . 2) choice selection is made 3)Checkable menu item is selected or deselected. ItemListener:- public void itemStateChanged(ItemEvent ie)

Page 52: Applet

Event Handling

AdjustmentEvent :-Scroll bar is manipulated .

AdjustementListener:- void adjustmentValueChanged(

AdjustmentEvent e);

Page 53: Applet

Event Handling

ComponentEvent:- when a component is hidden moved resized or become visible.

ComponentListener:-

void ComponentResized(ComponentEvevnt ce);void ComponentMoved(ComponentEvevnt ce);void ComponentShown(ComponentEvevnt ce);void ComponentHidden(ComponentEvevnt ce);

Page 54: Applet

Event Handling

FocusEvent :- Component gains or loses keyboard focus.

FocusListener:-

void focusGained(FocusEvent fe); void focusLost(FocusLost fl);

Page 55: Applet

Event Handling

ContainerEvent :- Component is added or removed from Container .

ContainerListener :- void componentAdded(ContainerEvent

ce) ;void

componentRemoved(ContainerEvent ce )

Page 56: Applet

Event Handling

KeyEvent:- Input is received from keyboard .

KeyListener:- void keyPressed(KeyEvent

ke); void keyReleased(KeyEvent

ke); void keyTyped(KeyEvent ke);

Page 57: Applet

Event Handling

MouseEvent :- When mouse is draggd, moved,clicked,pressed or released .

MouseListener :- void mouseClicked(MouseEvent me);void mouseEntered(MouseEvent me); void mouseDragged(MouseEvent me);

Page 58: Applet

Event Handling

void mousePressed(MouseEvent me); void mouseExited(MouseEvent me)

Page 59: Applet

Event Handling

MouseWheelEvent:- When mouse wheel is moved .

MouseWheelListener:-

void mouseWheelMoved(MouseWheelEvent mwe );

Page 60: Applet

Event Handling

TextEvent:- When the value of text area or text field is generated .

TextListener:- void textChanged(TextEvent

te);

Page 61: Applet

Event Handling

WindowEvent:- When window is activated, closed , deactivated, deiconified , iconified ,

opened or quit . WindowListener:- void windowActivated(WindowEvent we); void windowClosed(WindowEvent we); void windowClosing(WindowEvent we); void windowIconified(WindowEvent we); void windowDeiconified(WindowEvent we);

Page 62: Applet

Event Handling

void windowDeactivated(WindowEvent we);

void windowOpened(WindowEvent we);

Page 63: Applet

Inner class

Classes which is defined within another class. class A { Class B { } } A is container class or top level class. B is inner

class. One class can contain any no of inner class./Inner classs can contain inner class and this can go

upto any level.

Page 64: Applet

Inner class

Inner classes are of 4 types.

1)Static inner class 2)Non static inner class 3)Local inner class4) Anonymous inner class

Page 65: Applet

Inner class

Non static inner class:- This class ork as the member of class like

static inner class they can have any type of accessibility (public/private/protected/default),but like static inner class they can not have static members .

Because the non static class is the member of top level class and non static member exist when its object is created .The non static inner class doesn’t exist until the object of top level class created.

A non static inner class is always associated within the

object of top level class and therefore it has the special privilege it can access any member(static/non static) of its top level class . So that non static inner class is used for event handling.

Page 66: Applet

Panel

A Component which is used as a Container. It is used for physically grouping of Component.Constructor:- new Panel(); // Create the panel with Flow

layout Manager. new Panel(LayoutManager lm); // Create

the panel with same layoutManager by

which is pass as the parameter in the panel.

Page 67: Applet

Panel

Methods:- add(Component cmp);

add(Component cmp,int loc);

Page 68: Applet

Standalone application

To cretae a stand alone application we ned to create a class which will inherit Frame class . To run it we don’t need html ,this type of application has it ‘s own window. And this type of application created just like console based application.

Features of stand alone application.1) Standalone application is also called Frame.2)Frame provide the outlaw of window we only need to place

the components on window. 3)Frame has the same applarcchitecture and structure as the applet

and therefore GUI application and the event handling will be same as applet.

4)Like applet it doesn’t have init,start,stop,destroy,paint methods and therefore instead of initialize the applet we need we need to define the constructor of that class which inherit the Frame class.

5)To display standalone applicatio we need main method.just like console based application

Page 69: Applet

Standalone application

Import java.awt.*; Impoort java.applet.*; Import java.awt.event.*; public class Hobby extends Frame implements ItemListener{ --------------- -------------- public Hobbbby( )

{ ----------------- ------------------

------------------ same as init }

Page 70: Applet

Standalone application

Public void itemStateChanged(ItemListener il){

----------------------

}}

Page 71: Applet

Standalone application

public class HobbyGui { psvm(String arg[ ]){Hobby h=new Hobby();h.setSize(300,300);h.setVisible(true); }}

Page 72: Applet

Standalone application

import java.awt.*; import java.applet.*; import java.awt.event.*; class MyFrame extends Frame implements ActionListener { TextField t1,t2,t3; Button b1; FlowLayout fl; public MyFrame() { fl=new FlowLayout( ); setLayout(fl); t1=new TextField(5);

Page 73: Applet

Standalone application

t2=new TextField(5); t3=new TextField(5); b1=new Button("add"); add(t1); add(t2); add(t3); add(b1); b1.addActionListener(this); }

Page 74: Applet

Standalone application

public void actionPerformed(ActionEvent ae)

{ int i=Integer.parseInt(t1.getText()); int j=Integer.parseInt(t2.getText()); t3.setText(i+j+""); } }

Page 75: Applet

Standalone application

public class MyWindow { public static void main(String arg[]) { MyFrame mf=new MyFrame(); mf.setSize(300,300); mf.setVisible(true); } }

Page 76: Applet

Standalone application Some issues on Window:- When w click on crossbar th window

doesn’t terminate and still on RAM to close it we have to close the

DOS prompt because the event is generated by Frame we have to handle the event of Frame. There are 7 state of Frame when it generate event. In all 7 state it generate the WindowEvent .

To handle the 7 state of Frame WindowListener interface provide 7 different methods.When we implement the WindowListener we need to override the all 7 methods.

void windowActivated(WindowEvent we); void windowClosed(WindowEvent we); void windowClosing(WindowEvent we);

Page 77: Applet

Standalone application

void windowIconified(WindowEvent we);

void windowDeiconified(WindowEvent we);

void windowDeactivated(WindowEvent we);

void windowOpened(WindowEvent we);

Page 78: Applet

Standalone application

1) windowOpened is called after the application display on the screen . It called only once .It is used to initialize

the application.2)windowIconified is called when window is minimized .3) windowDeiconified is called when window is maximized .4) winowActivate is called when the application get the focus.5)windowDeactvate is called when the application lost the

focus.6)windowClosed is called when we click on cross button . 7)windowClosing dispose():- is called to terminate the application System.exit(0) :-is called to terminate the dos prompt or to

terminate the JVM.

Page 79: Applet

Standalone application

windowClosing is called when the application is dispose.It is used to save the state of application.This is called only once but closed is not called untill dispose is called .

Registration method :- void addindowListner(WindowEvent we)

Page 80: Applet

import java.awt.*; import java.applet.*; import java.awt.event.*; class MyFrame extends Frame

implements ActionListener,WindowListener

{ TextField t1,t2,t3; Button b1;

Page 81: Applet

FlowLayout fl; public MyFrame() { fl=new FlowLayout( ); setLayout(fl); t1=new TextField(5); t2=new TextField(5); t3=new TextField(5);

Page 82: Applet

b1=new Button("add"); add(t1); add(t2); add(t3); add(b1); b1.addActionListener(this); }

Page 83: Applet

public void actionPerformed(ActionEvent ae) { int i=Integer.parseInt(t1.getText()); int j=Integer.parseInt(t2.getText()); t3.setText(i+j+""); } public void windowActivated(WindowEvent we) { } public void windowClosed(WindowEvent we)

{dispose(); System.exit(0); } public void windowClosing(WindowEvent we) { }

Page 84: Applet

Standalone application

public void windowIconified(WindowEvent we) { }

public void windowDeiconified(WindowEvent we){ }

public void windowDeactivated(WindowEvent we) { }

public void windowOpened(WindowEvent we) { }

}

Page 85: Applet

Standalone application

public class MyWindowHandler { public static void main(String arg[]) { MyFrame mf=new MyFrame(); mf.setSize(300,300); mf.setVisible(true); } }

Page 86: Applet

Adapter class

WindowListener interface implements UserDefined class

Page 87: Applet

Adapter class

WindowListener interface

implements WindowAdapter class extends UserDefined class

Page 88: Applet

Adapter class

import java.awt.*; import java.applet.*; import java.awt.event.*; class MyFrame extends Frame implements

ActionListener,WindowAdapter { ------------------ ------------------ --------------------- public void windowClosed(WindowEvent we) { dispose(); System.exit(0); } ---------------------- -----------------

Page 89: Applet

Adapter class

--------------------- } public class MyWindowAdapter { public static void main(String arg[]) { ------------------- ------------------- --------------------- } }

Page 90: Applet

Adapter class

All listener those contain more than one

methods have Adapter classs. WindowListener . KeyListener MouseListener MouseMotionListener.