SlideShare a Scribd company logo
Assistant Professor
Assistant Professor
Department of Computer Science
Department of Computer Science
Kristu Jayanti College
Kristu Jayanti College
Bangalore
Bangalore
AWT CONTROLS
Presented by
November 29, 2024
November 29, 2024
1
1
Java Applet
Java Applet
2
2
Java AWT
Java AWT
 Java AWT
Java AWT (Abstract Window Toolkit) is an API to
(Abstract Window Toolkit) is an API to
develop GUI or window-based applications in java.
develop GUI or window-based applications in java.
 Java AWT components are platform-dependent
Java AWT components are platform-dependent
 The java.awt
The java.awt package provides classes for AWT api
package provides classes for AWT api
 such as TextField, Label, TextArea, RadioButton,
such as TextField, Label, TextArea, RadioButton,
CheckBox, Choice, List etc.
CheckBox, Choice, List etc.
November 29, 2024
November 29, 2024 Java Applet
Java Applet
Windows Fundamental
Windows Fundamental
Container
Container
 The Container is a component in AWT
The Container is a component in AWT
 That can contain another components
That can contain another components
like buttons, textfields, labels etc.
like buttons, textfields, labels etc.
 The classes that extends Container class
The classes that extends Container class
are known as container such as Frame,
are known as container such as Frame,
Dialog and Panel.
Dialog and Panel.
November 29, 2024
November 29, 2024 Java Applet
Java Applet
3
3
…
…Windows Fundamental
Windows Fundamental
Window
Window
 The window is the container
The window is the container
 Have no borders and menu bars.
Have no borders and menu bars.
 Frame, dialog or another window for creating a
Frame, dialog or another window for creating a
window.
window.
 Panel
Panel
 The Panel is the container
The Panel is the container
 that doesn't contain title bar and menu bars.
that doesn't contain title bar and menu bars.
 It can have other components like button,
It can have other components like button,
textfield etc.
textfield etc.
November 29, 2024
November 29, 2024 Java Applet
Java Applet
4
4
…
…Windows Fundamental
Windows Fundamental
Frame
Frame
 The Frame is the container
The Frame is the container
 That contain title bar and can have
That contain title bar and can have
menu bars.
menu bars.
 It can have other components like
It can have other components like
button, textfield etc.
button, textfield etc.
November 29, 2024
November 29, 2024 Java Applet
Java Applet
5
5
Methods of Component class
Methods of Component class
public void add(Component c)
public void add(Component c)
inserts a component on this component.
inserts a component on this component.
Ex: add(
Ex: add(b
b);
);
public void setSize(int width,int height)
public void setSize(int width,int height)
sets the size (width and height) of the
sets the size (width and height) of the
component.
component.
Ex: setSize(
Ex: setSize(300,300
300,300)
)
November 29, 2024
November 29, 2024 Java Applet
Java Applet
6
6
…
…Methods of Component class
Methods of Component class
public void setLayout(LayoutManager m)
public void setLayout(LayoutManager m)
defines the layout manager for the
defines the layout manager for the
component.
component.
Ex: setLayout(
Ex: setLayout(null
null);
);
public void setVisible(boolean status)
public void setVisible(boolean status)
changes the visibility of the component,
changes the visibility of the component,
by default false.
by default false.
Ex: setVisible(
Ex: setVisible(true
true);
);
November 29, 2024
November 29, 2024 Java Applet
Java Applet
7
7
Sample Code
Sample Code
import java.awt.*;
import java.awt.*;
class First1 extends Frame{
class First1 extends Frame{
First1(){
First1(){
Button b=new Button("click me");
Button b=new Button("click me");
b.setBounds(30,100,80,30);// setting button position
b.setBounds(30,100,80,30);// setting button position
add(b);//adding button into frame
add(b);//adding button into frame
setSize(300,300);//frame size 300 width and 300 height
setSize(300,300);//frame size 300 width and 300 height
setLayout(null);//no layout manager
setLayout(null);//no layout manager
setVisible(true);//now frame will be visible, by default not visible
setVisible(true);//now frame will be visible, by default not visible
}
}
public static void main(String args[]){
public static void main(String args[]){
First1 f=new First1();
First1 f=new First1();
}}
}}
November 29, 2024
November 29, 2024 Java Applet
Java Applet
8
8
Event and Listener
Event and Listener
 Changing the state
Changing the state of an object is
of an object is
known as an event.
known as an event.
 For example,
For example, click on button
click on button,
, dragging
dragging
mouse
mouse etc.
etc.
 The java.awt.event package provides
The java.awt.event package provides
many
many event classes
event classes and
and Listener
Listener
interfaces
interfaces for event handling.
for event handling.
November 29, 2024
November 29, 2024 Java Applet
Java Applet
9
9
Event classes and Listener interfaces
Event classes and Listener interfaces
Event Classes Listener Interfaces
ActionEvent ActionListener
MouseEvent MouseListener and
MouseMotionListener
MouseWheelEvent MouseWheelListener
KeyEvent KeyListener
ItemEvent ItemListener
TextEvent TextListener
AdjustmentEvent AdjustmentListener
WindowEvent WindowListener
ComponentEvent ComponentListener
ContainerEvent ContainerListener
FocusEvent FocusListener
November 29, 2024
November 29, 2024 Java Applet
Java Applet
10
10
Registration Methods
Registration Methods
 Button
Button
 public void addActionListener(ActionListener
public void addActionListener(ActionListener
a){}
a){}
 MenuItem
MenuItem
 public void addActionListener(ActionListener
public void addActionListener(ActionListener
a){}
a){}
 TextField
TextField
 public void addActionListener(ActionListener
public void addActionListener(ActionListener
a){}
a){}
 public void addTextListener(TextListener a){}
public void addTextListener(TextListener a){}
November 29, 2024
November 29, 2024 Java Applet
Java Applet
11
11
…
…Registration Methods
Registration Methods
 TextArea
TextArea
 public void addTextListener(TextListener a){}
public void addTextListener(TextListener a){}
 Checkbox
Checkbox
 public void addItemListener(ItemListener a){}
public void addItemListener(ItemListener a){}
 Choice
Choice
 public void addItemListener(ItemListener a){}
public void addItemListener(ItemListener a){}
 List
List
 public void addActionListener(ActionListener a)
public void addActionListener(ActionListener a)
{}
{}
 public void addItemListener(ItemListener a){}
public void addItemListener(ItemListener a){}
November 29, 2024
November 29, 2024 Java Applet
Java Applet
12
12
Sample Code
Sample Code
import java.awt.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.*;
class AEvent extends Frame implements ActionListener{
class AEvent extends Frame implements ActionListener{
TextField tf;
TextField tf;
AEvent(){
AEvent(){
//create components
//create components
tf=new TextField();
tf=new TextField();
tf.setBounds(60,50,170,20);
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
Button b=new Button("click me");
b.setBounds(100,120,80,30);
b.setBounds(100,120,80,30);
//register listener
//register listener
b.addActionListener(this);//passing current instance
b.addActionListener(this);//passing current instance
//add components and set size, layout and visibility
//add components and set size, layout and visibility
add(b);add(tf);
add(b);add(tf);
setSize(300,300);
setSize(300,300);
setLayout(null);
setLayout(null);
setVisible(true); }
setVisible(true); }
public void actionPerformed(ActionEvent e){
public void actionPerformed(ActionEvent e){
tf.setText("Welcome to III Maths"); }
tf.setText("Welcome to III Maths"); }
November 29, 2024
November 29, 2024 Java Applet
Java Applet
13
13
Button and Label
Button and Label
 The application result in some action
The application result in some action
when the button is pushed.
when the button is pushed.
Button b=new Button("Click Here");
Button b=new Button("Click Here");
 It is used to display a single line of read
It is used to display a single line of read
only text.
only text.
 The text can be changed by an
The text can be changed by an
application but a user cannot edit
application but a user cannot edit
Label l1=new Label("First Label.");
Label l1=new Label("First Label.");
November 29, 2024
November 29, 2024 Java Applet
Java Applet
14
14
TextField and TextArea
TextField and TextArea
 TextField class is a text component that
TextField class is a text component that
allows the editing of a single line text
allows the editing of a single line text
TextField t1=new TextField(“III Maths");
TextField t1=new TextField(“III Maths");
 TextArea class is a multi line region that
TextArea class is a multi line region that
displays text.
displays text.
 Editing of multiple line text.
Editing of multiple line text.
TextArea area=new TextArea("Welcome to III
TextArea area=new TextArea("Welcome to III
Maths");
Maths");
November 29, 2024
November 29, 2024 Java Applet
Java Applet
15
15
Checkbox and Choice
Checkbox and Choice
 The Checkbox class is used to create a
The Checkbox class is used to create a
checkbox.
checkbox.
 It is used to turn an option on (true) or off
It is used to turn an option on (true) or off
(false).
(false).
Checkbox checkbox1 = new Checkbox("C++");
Checkbox checkbox1 = new Checkbox("C++");
 Choice class is used to show popup menu
Choice class is used to show popup menu
of choices
of choices
Choice c=new Choice();
Choice c=new Choice();
November 29, 2024
November 29, 2024 Java Applet
Java Applet
16
16
MenuItem and Menu
MenuItem and Menu
 The object of MenuItem class adds a
The object of MenuItem class adds a
simple labeled menu item on menu
simple labeled menu item on menu
 The object of Menu class is a pull down
The object of Menu class is a pull down
menu
menu
MenuBar mb=new MenuBar();
MenuBar mb=new MenuBar();
Menu menu=new Menu("Menu");
Menu menu=new Menu("Menu");
November 29, 2024
November 29, 2024 Java Applet
Java Applet
17
17
PopupMenu
PopupMenu
 PopupMenu can be dynamically popped up
PopupMenu can be dynamically popped up
 Specific position within a component.
Specific position within a component.
 It inherits the Menu class.
It inherits the Menu class.
final
final PopupMenu popupmenu =
PopupMenu popupmenu = new
new Popup
Popup
Menu("Edit");
Menu("Edit");
MenuItem cut = new MenuItem("Cut");
MenuItem cut = new MenuItem("Cut");
November 29, 2024
November 29, 2024 Java Applet
Java Applet
18
18
Panel
Panel
 It provides space in which an
It provides space in which an
application can attach any other
application can attach any other
component
component
 It doesn't have title bar.
It doesn't have title bar.
Panel panel=new Panel();
Panel panel=new Panel();
November 29, 2024
November 29, 2024 Java Applet
Java Applet
19
19
Dialog
Dialog
 title used to take some form of input
title used to take some form of input
from the user
from the user
 it doesn't have maximize and minimize
it doesn't have maximize and minimize
buttons.
buttons.
Dialog d= new Dialog(f , "Dialog Example", true);
Dialog d= new Dialog(f , "Dialog Example", true);
November 29, 2024
November 29, 2024 Java Applet
Java Applet
20
20
ActionListener
ActionListener
 whenever you click on the button or
whenever you click on the button or
menu item
menu item
 It has only one method:
It has only one method:
actionPerformed()
actionPerformed()
public abstract void actionPerformed
public abstract void actionPerformed
(ActionEvent e);
(ActionEvent e);
November 29, 2024
November 29, 2024 Java Applet
Java Applet
21
21
MouseListener
MouseListener
 whenever you change the state of mouse
whenever you change the state of mouse
 It has five methods.
It has five methods.
 public
public abstract
abstract void
void mouse
mouseClicked
Clicked(MouseEvent e);
(MouseEvent e);
 public
public abstract
abstract void
void mouse
mouseEntered
Entered(MouseEvent e);
(MouseEvent e);
 public
public abstract
abstract void
void mouse
mouseExited
Exited(MouseEvent e);
(MouseEvent e);
 public
public abstract
abstract void
void mouse
mousePressed
Pressed(MouseEvent e);
(MouseEvent e);
 public
public abstract
abstract void
void mouse
mouseReleased
Released(MouseEvent e);
(MouseEvent e);
November 29, 2024
November 29, 2024 Java Applet
Java Applet
22
22
KeyListener
KeyListener
 whenever you change the state of key.
whenever you change the state of key.
 It is notified against KeyEvent
It is notified against KeyEvent
 public
public abstract
abstract void
void keyPressed
keyPressed(KeyEv
(KeyEv
ent e);
ent e);
 public
public abstract
abstract void
void keyReleased
keyReleased(KeyE
(KeyE
vent e);
vent e);
 public
public abstract
abstract void
void keyTyped
keyTyped(KeyEven
(KeyEven
t e);
t e);
November 29, 2024
November 29, 2024 Java Applet
Java Applet
23
23
November 29, 2024
November 29, 2024
24
24
Java Applet
Java Applet
Thank You

More Related Content

PPT
Basic of Abstract Window Toolkit(AWT) in Java
PPTX
javaprogramming framework-ppt frame.pptx
PPT
introduction to JAVA awt programmin .ppt
PPT
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
PPT
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
PPT
1.Abstract windowing toolkit.ppt of AJP sub
PPT
awt.ppt java windows programming lecture
PDF
GUI.pdf
Basic of Abstract Window Toolkit(AWT) in Java
javaprogramming framework-ppt frame.pptx
introduction to JAVA awt programmin .ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
1.Abstract windowing toolkit.ppt of AJP sub
awt.ppt java windows programming lecture
GUI.pdf

Similar to Java AWT Controls and methods, Listener classes (20)

PPT
Unit 1- awt(Abstract Window Toolkit) .ppt
PPT
28 awt
PDF
UNIT-2-AJAVA.pdf
PPTX
17625-1.pptx
PPTX
PPTX
tL19 awt
PPTX
JAVA AWT
PPT
Swing and AWT in java
PDF
Swingpre 150616004959-lva1-app6892
PPT
engineeringdsgtnotesofunitfivesnists.ppt
PPTX
Unit 5 java-awt (1)
PDF
PraveenKumar A T AWS
PDF
PDF
AWT (Abstract Window Toolkit) Controls.pdf
PPTX
JAVA AWT presentation for awt key events.pptx
PPT
events,key,life cycle-abstract window tool kit,abstract class
PPT
Awt and swing in java
PPTX
GUI (graphical user interface)
PPT
Unit 5.133333333333333333333333333333333.ppt
Unit 1- awt(Abstract Window Toolkit) .ppt
28 awt
UNIT-2-AJAVA.pdf
17625-1.pptx
tL19 awt
JAVA AWT
Swing and AWT in java
Swingpre 150616004959-lva1-app6892
engineeringdsgtnotesofunitfivesnists.ppt
Unit 5 java-awt (1)
PraveenKumar A T AWS
AWT (Abstract Window Toolkit) Controls.pdf
JAVA AWT presentation for awt key events.pptx
events,key,life cycle-abstract window tool kit,abstract class
Awt and swing in java
GUI (graphical user interface)
Unit 5.133333333333333333333333333333333.ppt
Ad

Recently uploaded (20)

PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Basic Mud Logging Guide for educational purpose
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Microbial diseases, their pathogenesis and prophylaxis
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Basic Mud Logging Guide for educational purpose
2.FourierTransform-ShortQuestionswithAnswers.pdf
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Open folder Downloads.pdf yes yes ges yes
O5-L3 Freight Transport Ops (International) V1.pdf
Cardiovascular Pharmacology for pharmacy students.pptx
Pharma ospi slides which help in ospi learning
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
The Final Stretch: How to Release a Game and Not Die in the Process.
Microbial diseases, their pathogenesis and prophylaxis
Ad

Java AWT Controls and methods, Listener classes

  • 1. Assistant Professor Assistant Professor Department of Computer Science Department of Computer Science Kristu Jayanti College Kristu Jayanti College Bangalore Bangalore AWT CONTROLS Presented by November 29, 2024 November 29, 2024 1 1 Java Applet Java Applet
  • 2. 2 2 Java AWT Java AWT  Java AWT Java AWT (Abstract Window Toolkit) is an API to (Abstract Window Toolkit) is an API to develop GUI or window-based applications in java. develop GUI or window-based applications in java.  Java AWT components are platform-dependent Java AWT components are platform-dependent  The java.awt The java.awt package provides classes for AWT api package provides classes for AWT api  such as TextField, Label, TextArea, RadioButton, such as TextField, Label, TextArea, RadioButton, CheckBox, Choice, List etc. CheckBox, Choice, List etc. November 29, 2024 November 29, 2024 Java Applet Java Applet
  • 3. Windows Fundamental Windows Fundamental Container Container  The Container is a component in AWT The Container is a component in AWT  That can contain another components That can contain another components like buttons, textfields, labels etc. like buttons, textfields, labels etc.  The classes that extends Container class The classes that extends Container class are known as container such as Frame, are known as container such as Frame, Dialog and Panel. Dialog and Panel. November 29, 2024 November 29, 2024 Java Applet Java Applet 3 3
  • 4. … …Windows Fundamental Windows Fundamental Window Window  The window is the container The window is the container  Have no borders and menu bars. Have no borders and menu bars.  Frame, dialog or another window for creating a Frame, dialog or another window for creating a window. window.  Panel Panel  The Panel is the container The Panel is the container  that doesn't contain title bar and menu bars. that doesn't contain title bar and menu bars.  It can have other components like button, It can have other components like button, textfield etc. textfield etc. November 29, 2024 November 29, 2024 Java Applet Java Applet 4 4
  • 5. … …Windows Fundamental Windows Fundamental Frame Frame  The Frame is the container The Frame is the container  That contain title bar and can have That contain title bar and can have menu bars. menu bars.  It can have other components like It can have other components like button, textfield etc. button, textfield etc. November 29, 2024 November 29, 2024 Java Applet Java Applet 5 5
  • 6. Methods of Component class Methods of Component class public void add(Component c) public void add(Component c) inserts a component on this component. inserts a component on this component. Ex: add( Ex: add(b b); ); public void setSize(int width,int height) public void setSize(int width,int height) sets the size (width and height) of the sets the size (width and height) of the component. component. Ex: setSize( Ex: setSize(300,300 300,300) ) November 29, 2024 November 29, 2024 Java Applet Java Applet 6 6
  • 7. … …Methods of Component class Methods of Component class public void setLayout(LayoutManager m) public void setLayout(LayoutManager m) defines the layout manager for the defines the layout manager for the component. component. Ex: setLayout( Ex: setLayout(null null); ); public void setVisible(boolean status) public void setVisible(boolean status) changes the visibility of the component, changes the visibility of the component, by default false. by default false. Ex: setVisible( Ex: setVisible(true true); ); November 29, 2024 November 29, 2024 Java Applet Java Applet 7 7
  • 8. Sample Code Sample Code import java.awt.*; import java.awt.*; class First1 extends Frame{ class First1 extends Frame{ First1(){ First1(){ Button b=new Button("click me"); Button b=new Button("click me"); b.setBounds(30,100,80,30);// setting button position b.setBounds(30,100,80,30);// setting button position add(b);//adding button into frame add(b);//adding button into frame setSize(300,300);//frame size 300 width and 300 height setSize(300,300);//frame size 300 width and 300 height setLayout(null);//no layout manager setLayout(null);//no layout manager setVisible(true);//now frame will be visible, by default not visible setVisible(true);//now frame will be visible, by default not visible } } public static void main(String args[]){ public static void main(String args[]){ First1 f=new First1(); First1 f=new First1(); }} }} November 29, 2024 November 29, 2024 Java Applet Java Applet 8 8
  • 9. Event and Listener Event and Listener  Changing the state Changing the state of an object is of an object is known as an event. known as an event.  For example, For example, click on button click on button, , dragging dragging mouse mouse etc. etc.  The java.awt.event package provides The java.awt.event package provides many many event classes event classes and and Listener Listener interfaces interfaces for event handling. for event handling. November 29, 2024 November 29, 2024 Java Applet Java Applet 9 9
  • 10. Event classes and Listener interfaces Event classes and Listener interfaces Event Classes Listener Interfaces ActionEvent ActionListener MouseEvent MouseListener and MouseMotionListener MouseWheelEvent MouseWheelListener KeyEvent KeyListener ItemEvent ItemListener TextEvent TextListener AdjustmentEvent AdjustmentListener WindowEvent WindowListener ComponentEvent ComponentListener ContainerEvent ContainerListener FocusEvent FocusListener November 29, 2024 November 29, 2024 Java Applet Java Applet 10 10
  • 11. Registration Methods Registration Methods  Button Button  public void addActionListener(ActionListener public void addActionListener(ActionListener a){} a){}  MenuItem MenuItem  public void addActionListener(ActionListener public void addActionListener(ActionListener a){} a){}  TextField TextField  public void addActionListener(ActionListener public void addActionListener(ActionListener a){} a){}  public void addTextListener(TextListener a){} public void addTextListener(TextListener a){} November 29, 2024 November 29, 2024 Java Applet Java Applet 11 11
  • 12. … …Registration Methods Registration Methods  TextArea TextArea  public void addTextListener(TextListener a){} public void addTextListener(TextListener a){}  Checkbox Checkbox  public void addItemListener(ItemListener a){} public void addItemListener(ItemListener a){}  Choice Choice  public void addItemListener(ItemListener a){} public void addItemListener(ItemListener a){}  List List  public void addActionListener(ActionListener a) public void addActionListener(ActionListener a) {} {}  public void addItemListener(ItemListener a){} public void addItemListener(ItemListener a){} November 29, 2024 November 29, 2024 Java Applet Java Applet 12 12
  • 13. Sample Code Sample Code import java.awt.*; import java.awt.*; import java.awt.event.*; import java.awt.event.*; class AEvent extends Frame implements ActionListener{ class AEvent extends Frame implements ActionListener{ TextField tf; TextField tf; AEvent(){ AEvent(){ //create components //create components tf=new TextField(); tf=new TextField(); tf.setBounds(60,50,170,20); tf.setBounds(60,50,170,20); Button b=new Button("click me"); Button b=new Button("click me"); b.setBounds(100,120,80,30); b.setBounds(100,120,80,30); //register listener //register listener b.addActionListener(this);//passing current instance b.addActionListener(this);//passing current instance //add components and set size, layout and visibility //add components and set size, layout and visibility add(b);add(tf); add(b);add(tf); setSize(300,300); setSize(300,300); setLayout(null); setLayout(null); setVisible(true); } setVisible(true); } public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){ tf.setText("Welcome to III Maths"); } tf.setText("Welcome to III Maths"); } November 29, 2024 November 29, 2024 Java Applet Java Applet 13 13
  • 14. Button and Label Button and Label  The application result in some action The application result in some action when the button is pushed. when the button is pushed. Button b=new Button("Click Here"); Button b=new Button("Click Here");  It is used to display a single line of read It is used to display a single line of read only text. only text.  The text can be changed by an The text can be changed by an application but a user cannot edit application but a user cannot edit Label l1=new Label("First Label."); Label l1=new Label("First Label."); November 29, 2024 November 29, 2024 Java Applet Java Applet 14 14
  • 15. TextField and TextArea TextField and TextArea  TextField class is a text component that TextField class is a text component that allows the editing of a single line text allows the editing of a single line text TextField t1=new TextField(“III Maths"); TextField t1=new TextField(“III Maths");  TextArea class is a multi line region that TextArea class is a multi line region that displays text. displays text.  Editing of multiple line text. Editing of multiple line text. TextArea area=new TextArea("Welcome to III TextArea area=new TextArea("Welcome to III Maths"); Maths"); November 29, 2024 November 29, 2024 Java Applet Java Applet 15 15
  • 16. Checkbox and Choice Checkbox and Choice  The Checkbox class is used to create a The Checkbox class is used to create a checkbox. checkbox.  It is used to turn an option on (true) or off It is used to turn an option on (true) or off (false). (false). Checkbox checkbox1 = new Checkbox("C++"); Checkbox checkbox1 = new Checkbox("C++");  Choice class is used to show popup menu Choice class is used to show popup menu of choices of choices Choice c=new Choice(); Choice c=new Choice(); November 29, 2024 November 29, 2024 Java Applet Java Applet 16 16
  • 17. MenuItem and Menu MenuItem and Menu  The object of MenuItem class adds a The object of MenuItem class adds a simple labeled menu item on menu simple labeled menu item on menu  The object of Menu class is a pull down The object of Menu class is a pull down menu menu MenuBar mb=new MenuBar(); MenuBar mb=new MenuBar(); Menu menu=new Menu("Menu"); Menu menu=new Menu("Menu"); November 29, 2024 November 29, 2024 Java Applet Java Applet 17 17
  • 18. PopupMenu PopupMenu  PopupMenu can be dynamically popped up PopupMenu can be dynamically popped up  Specific position within a component. Specific position within a component.  It inherits the Menu class. It inherits the Menu class. final final PopupMenu popupmenu = PopupMenu popupmenu = new new Popup Popup Menu("Edit"); Menu("Edit"); MenuItem cut = new MenuItem("Cut"); MenuItem cut = new MenuItem("Cut"); November 29, 2024 November 29, 2024 Java Applet Java Applet 18 18
  • 19. Panel Panel  It provides space in which an It provides space in which an application can attach any other application can attach any other component component  It doesn't have title bar. It doesn't have title bar. Panel panel=new Panel(); Panel panel=new Panel(); November 29, 2024 November 29, 2024 Java Applet Java Applet 19 19
  • 20. Dialog Dialog  title used to take some form of input title used to take some form of input from the user from the user  it doesn't have maximize and minimize it doesn't have maximize and minimize buttons. buttons. Dialog d= new Dialog(f , "Dialog Example", true); Dialog d= new Dialog(f , "Dialog Example", true); November 29, 2024 November 29, 2024 Java Applet Java Applet 20 20
  • 21. ActionListener ActionListener  whenever you click on the button or whenever you click on the button or menu item menu item  It has only one method: It has only one method: actionPerformed() actionPerformed() public abstract void actionPerformed public abstract void actionPerformed (ActionEvent e); (ActionEvent e); November 29, 2024 November 29, 2024 Java Applet Java Applet 21 21
  • 22. MouseListener MouseListener  whenever you change the state of mouse whenever you change the state of mouse  It has five methods. It has five methods.  public public abstract abstract void void mouse mouseClicked Clicked(MouseEvent e); (MouseEvent e);  public public abstract abstract void void mouse mouseEntered Entered(MouseEvent e); (MouseEvent e);  public public abstract abstract void void mouse mouseExited Exited(MouseEvent e); (MouseEvent e);  public public abstract abstract void void mouse mousePressed Pressed(MouseEvent e); (MouseEvent e);  public public abstract abstract void void mouse mouseReleased Released(MouseEvent e); (MouseEvent e); November 29, 2024 November 29, 2024 Java Applet Java Applet 22 22
  • 23. KeyListener KeyListener  whenever you change the state of key. whenever you change the state of key.  It is notified against KeyEvent It is notified against KeyEvent  public public abstract abstract void void keyPressed keyPressed(KeyEv (KeyEv ent e); ent e);  public public abstract abstract void void keyReleased keyReleased(KeyE (KeyE vent e); vent e);  public public abstract abstract void void keyTyped keyTyped(KeyEven (KeyEven t e); t e); November 29, 2024 November 29, 2024 Java Applet Java Applet 23 23
  • 24. November 29, 2024 November 29, 2024 24 24 Java Applet Java Applet Thank You