SlideShare a Scribd company logo
AWT COMPONENTS
Text area


 Sometimes a single line of text input is not enough
  for a given task so to solve this problem we use text
  area.
 TextArea is a subclass of TextComponent.
Text area constructors

 TextArea( )
 TextArea(int numLines, int numChars)
 TextArea(String str)
 TextArea(String str, int numLines, int numChars)
Text area constructor

 TextArea(String str, int numLines, int numChars, int
    sBars)
   sBars have following values
   SCROLLBARS_BOTH
   SCROLLBARS_NONE
   SCROLLBARS_HORIZONTAL_ONLY
    SCROLLBARS_VERTICAL_ONLY
Textarea functions

 getText( )
 setText( ),
 getSelectedText( )
 select( )
 isEditable( )
 setEditable( )
Textarea functions

 void append(String str)
 void insert(String str, int index)
 void replaceRange(String str, int startIndex, int
 endIndex)
// Demonstrate TextArea.
import java.awt.*;
import java.applet.*;
/*
<applet code="TextAreaDemo" width=300 height=250>
</applet>
*/
public class TextAreaDemo extends Applet
 {
   public void init() {
        String val = "There are two ways of constructing " +
        "a software design.n" +
        "One way is to make it so simplen" +
        "that there are obviously no deficiencies.n" +
        "And the other way is to make it so complicatedn" +
        TextArea text = new TextArea(val, 10, 30);
        add(text);
}
}
Check boxes

 Checkboxes are created by Mycheckbox class.
 init( ) method creates instances of MyCheckbox and
 adds these to the applet
/*
* <applet code=CheckboxDemo2 width=300 height=100>
* </applet>
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class CheckboxDemo2 extends Applet
 {
   MyCheckbox myCheckbox1, myCheckbox2, myCheckbox3;
   public void init() {
        myCheckbox1 = new MyCheckbox("Item 1");
        add(myCheckbox1);
        myCheckbox2 = new MyCheckbox("Item 2");
        add(myCheckbox2);
        myCheckbox3 = new MyCheckbox("Item 3");
        add(myCheckbox3);}
}
Check box group

 Group of checkboxes creates checkbox.
 For this checkboxGroup class is used.
public class CheckboxGroupDemo2 extends Applet
{
  CheckboxGroup cbg;
  MyCheckbox myCheckbox1, myCheckbox2, myCheckbox3;
  public void init() {
        cbg = new CheckboxGroup();
        myCheckbox1 = new MyCheckbox("Item 1", cbg, true);
        add(myCheckbox1);
        myCheckbox2 = new MyCheckbox("Item 2", cbg, false);
        add(myCheckbox2);
        myCheckbox3 = new MyCheckbox("Item 3", cbg, false);
        add(myCheckbox3);
}
Radio Button or Choice

 To choose one option between many choices radio
  button is used.
 For making radio buttons Mychoice class is used.
/*
* <applet code=ChoiceDemo2 width=300 height=100>
* </applet>
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ChoiceDemo2 extends Applet {
   MyChoice choice;
   public void init() {
          choice = new MyChoice();
          choice.add("Red");
          choice.add("Green");
          choice.add("Blue");
          add(choice);
}
lists
 For creating lists Mylist class is used.
/*
* <applet code=ListDemo2 width=300 height=100>
* </applet>
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ListDemo2 extends Applet {
   MyList list;
   public void init() {
        list = new MyList();
        list.add("Red");
        list.add("Green");
        list.add("Blue");
        add(list);
}
Creating an image

 createImage( ) that is used to create Image objects.


 Image createImage(ImageProducer imgProd)
 Image createImage(int width, int height)
Loading an image

 use the getImage( ).


 Image getImage(URL url)
 Image getImage(URL url, String imageName)
Displaying an image

 For dispalying an image we use drawImage(),which
 is a method of object class.

 boolean drawImage(Image imgObj, int left, int top,
 ImageObserver imgOb)
/*
* <applet code="SimpleImageLoad" width=248 height=146>
* <param name="img" value="seattle.jpg">
* </applet>
*/
import java.awt.*;
import java.applet.*;
public class SimpleImageLoad extends Applet
{
   Image img;
   public void init() {
        img = getImage(getDocumentBase(), getParameter("img"));
}
   public void paint(Graphics g) {
        g.drawImage(img, 0, 0, this);
}
}
Conclusion
THANKS

More Related Content

PPT
AWT information
PPT
PPTX
PPT
28 awt
PPT
Awt controls ppt
PDF
Java awt tutorial javatpoint
PPT
25 awt
PPTX
Java awt (abstract window toolkit)
AWT information
28 awt
Awt controls ppt
Java awt tutorial javatpoint
25 awt
Java awt (abstract window toolkit)

What's hot (20)

PPSX
Dr. Rajeshree Khande :Introduction to Java AWT
PPT
Windows Programming with AWT
PPTX
tL19 awt
PPT
Java awt
PPT
Basic of Abstract Window Toolkit(AWT) in Java
PPTX
java-Unit4 chap2- awt controls and layout managers of applet
PPTX
JAVA AWT
PPTX
Event handling
PPT
Awt and swing in java
PDF
The AWT and Swing
PPTX
GUI components in Java
PPT
Unit 6 Java
PPTX
GUI (graphical user interface)
PDF
PPTX
Java- GUI- Mazenet solution
PPTX
Java chapter 7
PPTX
object oriented programming examples
PPTX
AWT Packages , Containers and Components
PPT
Swing and Graphical User Interface in Java
Dr. Rajeshree Khande :Introduction to Java AWT
Windows Programming with AWT
tL19 awt
Java awt
Basic of Abstract Window Toolkit(AWT) in Java
java-Unit4 chap2- awt controls and layout managers of applet
JAVA AWT
Event handling
Awt and swing in java
The AWT and Swing
GUI components in Java
Unit 6 Java
GUI (graphical user interface)
Java- GUI- Mazenet solution
Java chapter 7
object oriented programming examples
AWT Packages , Containers and Components
Swing and Graphical User Interface in Java
Ad

Similar to Awt components (20)

PPTX
PPT
PDF
Object Oriented Solved Practice Programs C++ Exams
PPT
Unit 1- awt(Abstract Window Toolkit) .ppt
PPT
introduction to JAVA awt programmin .ppt
PPT
1.Abstract windowing toolkit.ppt of AJP sub
PPT
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
PPT
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
PPT
awt.ppt java windows programming lecture
DOCX
Java practical
PPT
Advance Java Programming (CM5I) 1.AWT
PDF
The Ring programming language version 1.3 book - Part 83 of 88
PDF
Advanced Java - Practical File
ODT
Eclipse Tricks
ODT
Java practical
DOC
DOCX
single-value annotation
PDF
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
DOC
code for quiz in my sql
PDF
Unit-2 swing and mvc architecture
Object Oriented Solved Practice Programs C++ Exams
Unit 1- awt(Abstract Window Toolkit) .ppt
introduction to JAVA awt programmin .ppt
1.Abstract windowing toolkit.ppt of AJP sub
fdtrdrtttxxxtrtrctctrttrdredrerrrrrrawt.ppt
awdrdtfffyfyfyfyfyfyfyfyfyfyfyfyyfyt.ppt
awt.ppt java windows programming lecture
Java practical
Advance Java Programming (CM5I) 1.AWT
The Ring programming language version 1.3 book - Part 83 of 88
Advanced Java - Practical File
Eclipse Tricks
Java practical
single-value annotation
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
code for quiz in my sql
Unit-2 swing and mvc architecture
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Lesson notes of climatology university.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Classroom Observation Tools for Teachers
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
Supply Chain Operations Speaking Notes -ICLT Program
TR - Agricultural Crops Production NC III.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Cell Structure & Organelles in detailed.
Pharma ospi slides which help in ospi learning
Microbial diseases, their pathogenesis and prophylaxis
Abdominal Access Techniques with Prof. Dr. R K Mishra
Lesson notes of climatology university.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
Computing-Curriculum for Schools in Ghana
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Classroom Observation Tools for Teachers
01-Introduction-to-Information-Management.pdf
Institutional Correction lecture only . . .
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Complications of Minimal Access Surgery at WLH

Awt components

  • 2. Text area  Sometimes a single line of text input is not enough for a given task so to solve this problem we use text area.  TextArea is a subclass of TextComponent.
  • 3. Text area constructors  TextArea( )  TextArea(int numLines, int numChars)  TextArea(String str)  TextArea(String str, int numLines, int numChars)
  • 4. Text area constructor  TextArea(String str, int numLines, int numChars, int sBars)  sBars have following values  SCROLLBARS_BOTH  SCROLLBARS_NONE  SCROLLBARS_HORIZONTAL_ONLY SCROLLBARS_VERTICAL_ONLY
  • 5. Textarea functions  getText( )  setText( ),  getSelectedText( )  select( )  isEditable( )  setEditable( )
  • 6. Textarea functions  void append(String str)  void insert(String str, int index)  void replaceRange(String str, int startIndex, int endIndex)
  • 7. // Demonstrate TextArea. import java.awt.*; import java.applet.*; /* <applet code="TextAreaDemo" width=300 height=250> </applet> */ public class TextAreaDemo extends Applet { public void init() { String val = "There are two ways of constructing " + "a software design.n" + "One way is to make it so simplen" + "that there are obviously no deficiencies.n" + "And the other way is to make it so complicatedn" + TextArea text = new TextArea(val, 10, 30); add(text); } }
  • 8. Check boxes  Checkboxes are created by Mycheckbox class.  init( ) method creates instances of MyCheckbox and adds these to the applet
  • 9. /* * <applet code=CheckboxDemo2 width=300 height=100> * </applet> */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class CheckboxDemo2 extends Applet { MyCheckbox myCheckbox1, myCheckbox2, myCheckbox3; public void init() { myCheckbox1 = new MyCheckbox("Item 1"); add(myCheckbox1); myCheckbox2 = new MyCheckbox("Item 2"); add(myCheckbox2); myCheckbox3 = new MyCheckbox("Item 3"); add(myCheckbox3);} }
  • 10. Check box group  Group of checkboxes creates checkbox.  For this checkboxGroup class is used.
  • 11. public class CheckboxGroupDemo2 extends Applet { CheckboxGroup cbg; MyCheckbox myCheckbox1, myCheckbox2, myCheckbox3; public void init() { cbg = new CheckboxGroup(); myCheckbox1 = new MyCheckbox("Item 1", cbg, true); add(myCheckbox1); myCheckbox2 = new MyCheckbox("Item 2", cbg, false); add(myCheckbox2); myCheckbox3 = new MyCheckbox("Item 3", cbg, false); add(myCheckbox3); }
  • 12. Radio Button or Choice  To choose one option between many choices radio button is used.  For making radio buttons Mychoice class is used.
  • 13. /* * <applet code=ChoiceDemo2 width=300 height=100> * </applet> */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class ChoiceDemo2 extends Applet { MyChoice choice; public void init() { choice = new MyChoice(); choice.add("Red"); choice.add("Green"); choice.add("Blue"); add(choice); }
  • 14. lists  For creating lists Mylist class is used. /* * <applet code=ListDemo2 width=300 height=100> * </applet> */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class ListDemo2 extends Applet { MyList list; public void init() { list = new MyList(); list.add("Red"); list.add("Green"); list.add("Blue"); add(list); }
  • 15. Creating an image  createImage( ) that is used to create Image objects.  Image createImage(ImageProducer imgProd)  Image createImage(int width, int height)
  • 16. Loading an image  use the getImage( ).  Image getImage(URL url)  Image getImage(URL url, String imageName)
  • 17. Displaying an image  For dispalying an image we use drawImage(),which is a method of object class.  boolean drawImage(Image imgObj, int left, int top, ImageObserver imgOb)
  • 18. /* * <applet code="SimpleImageLoad" width=248 height=146> * <param name="img" value="seattle.jpg"> * </applet> */ import java.awt.*; import java.applet.*; public class SimpleImageLoad extends Applet { Image img; public void init() { img = getImage(getDocumentBase(), getParameter("img")); } public void paint(Graphics g) { g.drawImage(img, 0, 0, this); } }