SlideShare a Scribd company logo
1 of 9
AWT
CONTROLS
Adding and Removing Controls
➔ To include a control in a window, you must add it to the window. To do this,
you must first create an instance of the desired control and then add it to a
window by calling add( ),
➔ Which is defined by Container. The add( ) method has several forms.
➔ The following form is the one that is used for the first part of this chapter:
Component add(Component compObj)
➔ Here, compObj is an instance of the control that you want to add. A reference
to compObj is returned. Once a control has been added, it will automatically
be visible whenever its parent window is displayed.
CONTROL FUNDAMENTALS
The AWT supports the following types of controls
• Labels
• Push buttons
• Check boxes
• Choice lists
• Lists
• Scroll bars
• Text editing
JAVA AWT LABEL
➔ Label is the easiest control.
➔ It is used to display a single line of read only text.
➔ The text can be changed by a programmer but a user cannot edit it directly.
➔ Labels are passive controls that do not support any interaction with the user
Label defines the following constructors:
Label( ) throws HeadlessException
Label(String str) throws HeadlessException
Label(String str, int how) throws HeadlessException
➔ The first version creates a blank label.
➔ The second version creates a label that contains the string specified by str.
This string is left-justified.
➔ The third version creates a label that contains the string specified by str
using the alignment specified by how.
➔ The value of how must be one of these three constants: Label.LEFT,
Label.RIGHT, or Label.CENTER.
➔ You can set or change the text in a label by using the setText( ) method. You
can obtain the current label by calling getText( ). These methods are shown
here:
➔ void setText(String str)
➔ String getText( )
LabelExample.java
import java.awt.*;
public class LabelExample {
public static void main(String args[]){
// creating the object of Frame class and Label class
Frame f= new Frame ("Label example");
Label 11, 12;
// initializing the labels
11 = new Label ("First Label.");
12 = new Label ("Second Label.");
// set the location of label
11.setBounds(50, 100, 100, 30);
12.setBounds(50, 150, 100, 30);
// adding labels to the frame
fadd(I1): f.add(12);
/ setting size, layout and visibility of frame
fsetSize(400,400);
fsetLayout(null);
f.set Visible(true);
}
}
JAVA AWT BUTTON
➔ A button is basically a control component with a label that generates an
event when pushed.
➔ The Button class is used to create a labeled button that has platform
independent implementation
➔ When we press a button and release it, AWT sends an instance of Action
Event to that button by calling processEvent on the button
➔ The processEvent method of the button receives the all the events, then it
passes an action event by calling its own method processAction Event
➔ This method passes the action event on to action listeners that are
interested in the action events generated by the button
➔ The registered new listener can receive events from the button by calling
addActionListener method of the button
➔ The Java application can use the button's action command as a messaging
protocol
THANKS

More Related Content

Similar to awt controls .pptx

Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managersswapnac12
 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupalguest6fb0ef
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcelRavi Gajul
 
Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)Ehtisham Ali
 
Adv excel® 2013
Adv excel® 2013Adv excel® 2013
Adv excel® 2013Raghu nath
 
e computer notes - Including constraints
e computer notes - Including constraintse computer notes - Including constraints
e computer notes - Including constraintsecomputernotes
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window ToolkitRutvaThakkar1
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Ali Raza Zaidi
 
Aspnet mvc tutorial_9_cs
Aspnet mvc tutorial_9_csAspnet mvc tutorial_9_cs
Aspnet mvc tutorial_9_csMurali G
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sqlNazir Ahmed
 

Similar to awt controls .pptx (20)

Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
Blocks In Drupal
Blocks In DrupalBlocks In Drupal
Blocks In Drupal
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcel
 
Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)
 
Lecture7 oopj
Lecture7 oopjLecture7 oopj
Lecture7 oopj
 
Adv excel® 2013
Adv excel® 2013Adv excel® 2013
Adv excel® 2013
 
Excel® 2013
Excel® 2013Excel® 2013
Excel® 2013
 
Android interface elements and controls-chapter8
Android interface elements and controls-chapter8Android interface elements and controls-chapter8
Android interface elements and controls-chapter8
 
e computer notes - Including constraints
e computer notes - Including constraintse computer notes - Including constraints
e computer notes - Including constraints
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
Excel 2013
Excel 2013Excel 2013
Excel 2013
 
Java swing
Java swingJava swing
Java swing
 
AWT.pptx
AWT.pptxAWT.pptx
AWT.pptx
 
Les10
Les10Les10
Les10
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3
 
Aspnet mvc tutorial_9_cs
Aspnet mvc tutorial_9_csAspnet mvc tutorial_9_cs
Aspnet mvc tutorial_9_cs
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sql
 
Fewd week8 slides
Fewd week8 slidesFewd week8 slides
Fewd week8 slides
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

awt controls .pptx

  • 2. Adding and Removing Controls ➔ To include a control in a window, you must add it to the window. To do this, you must first create an instance of the desired control and then add it to a window by calling add( ), ➔ Which is defined by Container. The add( ) method has several forms. ➔ The following form is the one that is used for the first part of this chapter: Component add(Component compObj) ➔ Here, compObj is an instance of the control that you want to add. A reference to compObj is returned. Once a control has been added, it will automatically be visible whenever its parent window is displayed.
  • 3. CONTROL FUNDAMENTALS The AWT supports the following types of controls • Labels • Push buttons • Check boxes • Choice lists • Lists • Scroll bars • Text editing
  • 4. JAVA AWT LABEL ➔ Label is the easiest control. ➔ It is used to display a single line of read only text. ➔ The text can be changed by a programmer but a user cannot edit it directly. ➔ Labels are passive controls that do not support any interaction with the user Label defines the following constructors: Label( ) throws HeadlessException Label(String str) throws HeadlessException Label(String str, int how) throws HeadlessException ➔ The first version creates a blank label. ➔ The second version creates a label that contains the string specified by str. This string is left-justified. ➔ The third version creates a label that contains the string specified by str using the alignment specified by how.
  • 5. ➔ The value of how must be one of these three constants: Label.LEFT, Label.RIGHT, or Label.CENTER. ➔ You can set or change the text in a label by using the setText( ) method. You can obtain the current label by calling getText( ). These methods are shown here: ➔ void setText(String str) ➔ String getText( ) LabelExample.java import java.awt.*; public class LabelExample { public static void main(String args[]){ // creating the object of Frame class and Label class Frame f= new Frame ("Label example"); Label 11, 12; // initializing the labels 11 = new Label ("First Label."); 12 = new Label ("Second Label.");
  • 6. // set the location of label 11.setBounds(50, 100, 100, 30); 12.setBounds(50, 150, 100, 30); // adding labels to the frame fadd(I1): f.add(12); / setting size, layout and visibility of frame fsetSize(400,400); fsetLayout(null); f.set Visible(true); } }
  • 7. JAVA AWT BUTTON ➔ A button is basically a control component with a label that generates an event when pushed. ➔ The Button class is used to create a labeled button that has platform independent implementation ➔ When we press a button and release it, AWT sends an instance of Action Event to that button by calling processEvent on the button ➔ The processEvent method of the button receives the all the events, then it passes an action event by calling its own method processAction Event ➔ This method passes the action event on to action listeners that are interested in the action events generated by the button ➔ The registered new listener can receive events from the button by calling addActionListener method of the button ➔ The Java application can use the button's action command as a messaging protocol
  • 8.