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  are...
Text area constructors TextArea( ) TextArea(int numLines, int numChars) TextArea(String str) TextArea(String str, int ...
Text area constructor TextArea(String str, int numLines, int numChars, int    sBars)   sBars have following values   SC...
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 startIn...
// Demonstrate TextArea.import java.awt.*;import java.applet.*;/*<applet code="TextAreaDemo" width=300 height=250></applet...
Check boxes Checkboxes are created by Mycheckbox class. init( ) method creates instances of MyCheckbox and adds these to...
/** <applet code=CheckboxDemo2 width=300 height=100>* </applet>*/import java.awt.*;import java.awt.event.*;import java.app...
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;  pu...
Radio Button or Choice To choose one option between many choices radio  button is used. For making radio buttons Mychoic...
/** <applet code=ChoiceDemo2 width=300 height=100>* </applet>*/import java.awt.*;import java.awt.event.*;import java.apple...
lists For creating lists Mylist class is used./** <applet code=ListDemo2 width=300 height=100>* </applet>*/import java.aw...
Creating an image createImage( ) that is used to create Image objects. Image createImage(ImageProducer imgProd) Image c...
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(Imag...
/** <applet code="SimpleImageLoad" width=248 height=146>* <param name="img" value="seattle.jpg">* </applet>*/import java.a...
Conclusion
THANKS
Upcoming SlideShare
Loading in...5
×

Awt components

256

Published on

information about awt components

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
256
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Awt components

  1. 1. AWT COMPONENTS
  2. 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. 3. Text area constructors TextArea( ) TextArea(int numLines, int numChars) TextArea(String str) TextArea(String str, int numLines, int numChars)
  4. 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. 5. Textarea functions getText( ) setText( ), getSelectedText( ) select( ) isEditable( ) setEditable( )
  6. 6. Textarea functions void append(String str) void insert(String str, int index) void replaceRange(String str, int startIndex, int endIndex)
  7. 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. 8. Check boxes Checkboxes are created by Mycheckbox class. init( ) method creates instances of MyCheckbox and adds these to the applet
  9. 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. 10. Check box group Group of checkboxes creates checkbox. For this checkboxGroup class is used.
  11. 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. 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. 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. 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. 15. Creating an image createImage( ) that is used to create Image objects. Image createImage(ImageProducer imgProd) Image createImage(int width, int height)
  16. 16. Loading an image use the getImage( ). Image getImage(URL url) Image getImage(URL url, String imageName)
  17. 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. 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);}}
  19. 19. Conclusion
  20. 20. THANKS
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×