SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDrRajeshreeKhande
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWTbackdoor
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletraksharao
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swingadil raja
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)rishi ram khanal
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solutionMazenetsolution
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examplesAbdii Rashid
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and ComponentsSohanur63
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Javababak danyal
 

Was ist angesagt? (20)

Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Java awt
Java awtJava awt
Java awt
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Event handling
Event handlingEvent handling
Event handling
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
Gui
GuiGui
Gui
 
Swing
SwingSwing
Swing
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
 

Ähnlich wie Awt components

Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTPayal Dungarwal
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical FileFahad Shaikh
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architectureAmol Gaikwad
 
Prompt the user to enter five numbers, being five peoples weights..pdf
Prompt the user to enter five numbers, being five peoples weights..pdfPrompt the user to enter five numbers, being five peoples weights..pdf
Prompt the user to enter five numbers, being five peoples weights..pdfJUSTSTYLISH3B2MOHALI
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentnidhileena
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014First Tuesday Bergen
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210Mahmoud Samir Fayed
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 

Ähnlich wie Awt components (20)

Applet
AppletApplet
Applet
 
Java awt
Java awtJava awt
Java awt
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Java practical
Java practicalJava practical
Java practical
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWT
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Java practical
Java practicalJava practical
Java practical
 
Awt
AwtAwt
Awt
 
single-value annotation
single-value annotationsingle-value annotation
single-value annotation
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architecture
 
Prompt the user to enter five numbers, being five peoples weights..pdf
Prompt the user to enter five numbers, being five peoples weights..pdfPrompt the user to enter five numbers, being five peoples weights..pdf
Prompt the user to enter five numbers, being five peoples weights..pdf
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Dependency Injection for Android
Dependency Injection for AndroidDependency Injection for Android
Dependency Injection for Android
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210
 
AWT New-3.pptx
AWT New-3.pptxAWT New-3.pptx
AWT New-3.pptx
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 

Kürzlich hochgeladen

P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
How to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingHow to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingCeline George
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfNOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfSumit Tiwari
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxiammrhaywood
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational PhilosophyShuvankar Madhu
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
How to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingHow to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 Accounting
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdfNOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
NOTES OF DRUGS ACTING ON NERVOUS SYSTEM .pdf
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational Philosophy
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 

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); } }