SlideShare a Scribd company logo
1 of 25
Rakesh Ravaso Patil
Dept. of Computer Engg.
T.E. „B‟ 12276
Overview…
 Introduction to AWT
    Swing vs. AWT
 Building GUI
 Component Hierarchy
 AWT Control Fundamentals
 Adding Components
 Arranging Components
 Overview of Event Handling
 Working with Graphics
 Conclusion
AWT (Abstract Window Toolkit)
 Present in all Java implementations

 Adequate for many applications

 Uses the controls defined by your OS

 Difficult to build an attractive GUI

 import java.awt.*;
 import java.awt.event.*;
Swing
 Same concepts as AWT
 Doesn‟t work in ancient Java implementations (Java
  1.1 and earlier)
 Many more controls, and they are more flexible
   Some controls, but not all, are a lot more complicated
 Gives a choice of “look and feel” packages
 Much easier to build an attractive GUI
 import javax.swing.*;
Swing vs. AWT
 Swing is bigger, slower, and more complicated
    But not as slow as it used to be
 Swing is more flexible and better looking
 Swing and AWT are incompatible--you can use
 either, but you can‟t mix them
   Actually, you can, but it‟s tricky and not worth doing
 Learning the AWT is a good start on learning Swing
 Many of the most common controls are just renamed
    AWT: Button b = new Button ("OK");
    Swing: JButton b = new JButton("OK");
To build a GUI...
 Create some Components, such as buttons, text
  areas, panels, etc.
 Add your Components to your display area
 Arrange, or lay out, your Components
 Attach Listeners to your Components
   Interacting with a Component causes an Event to occur
   A Listener gets a message when an interesting event
    occurs, and executes some code to deal with it
An Applet is Panel is Container
java.lang.Object
  |
  +----java.awt.Component
       |
       +----java.awt.Container
           |
           +----java.awt.Panel
                |
                +----java.applet.Applet
  …so you can display things in an Applet
Example: A "Life" applet
               Container (Applet)

               Containers (Panels)


                Component (Canvas)


                Components (Buttons)


                Components (TextFields)

                Components (Labels)
Some types of components
   Label           Button             Checkbox




  Choice                                          Scrollbar


TextField   List                                  TextArea


 Button




                       Checkbox   CheckboxGroup
Creating components
 Label lab = new Label ("Hi, Dave!");
 Button but = new Button ("Click me!");
 Checkbox toggle = new Checkbox ("toggle");
 TextField txt =
    new TextField ("Initial text.", 20);
 Scrollbar scrolly = new Scrollbar
   (Scrollbar.HORIZONTAL, initialValue,
    bubbleSize, minValue, maxValue);
Adding components to the Applet
  class MyApplet extends Applet {
     public void init () {
      add (lab); // same as this.add(lab)
      add (but);
      add (toggle);
      add (txt);
      add (scrolly);
      ...
Arranging components
 Every Container has a layout manager
 The default layout for a Panel is FlowLayout
 An Applet is a Panel
 Therefore, the default layout for a Applet is
  FlowLayout
 You could set it explicitly with
    setLayout (new FlowLayout( ));
 You could change it to some other layout manager
Flow Layout
 Use add(component); to add to a
    component when using a
    FlowLayout
   Components are added left-to-right
   If no room, a new row is started
   Exact layout depends on size of
    Applet
   Components are made as small as
    possible
   FlowLayout is convenient but often
    ugly
BorderLayout
 At most five components
  can be added
 If you want more
  components, add a
 Panel, then add
 components to it.
•setLayout (new BorderLayout());
GridLayout
 The GridLayout
  manager divides the
  container up into a
  given number of rows
  and columns:
 new GridLayout(rows,
  columns)

•All sections of the grid are equally sized and as
large as possible
Making components active
 Most components already appear to do something--
  buttons click, text appears
 To associate an action with a component, attach a
  listener to it
 Components send events, listeners listen for events
 Different components may send different events, and
  require different listeners
Listeners
 Listeners are interfaces, not classes
    class MyButtonListener implements
          ActionListener {
 An interface is a group of methods that must be
  supplied
 When you say implements, you are promising to
  supply those methods
Writing a Listener
 For a Button, you need an ActionListener

    b1.addActionListener
       (new MyButtonListener ( ));

 An ActionListener must have an
 actionPerformed(ActionEvent) method

    public void actionPerformed(ActionEvent e) {
      …
    }
Listeners for TextFields
 An ActionListener listens for someone hitting the
  Enter key
 An ActionListener requires this method:
    public void actionPerformed (ActionEvent e)
 You can use getText( ) to get the text

 A TextListener listens for any and all keys
 A TextListener requires this method:
    public void textValueChanged(TextEvent e)
Working With Graphics
                Circle               Triangle
   Rounded
   Rectangle   Arc

                                        Ellipse




                         Rectangle
 Lines
Working with Graphics
 void drawLine(int x1, int y1, int x2, int y2)
 void drawRect(int top, int left, int width, int height)
 void drawRoundRect(int top, int left,int width, int
            height, int xDiam, int yDiam)
 void drawOvel(int top, int left, int width, int height)
 void drawArc(int top, int left, int width,int height, int
            startAngle, int sweepAngle)
 void drawPoly(int x[], int y[], int numPoints)

 void fill….
Format Shape
 Working with colors
   HSB
   RGB
   static int HSBtoRGB(float hue, float saturation, float
                                         brightness)
   Static float[] RGBtoHSB(int red, int green, int blue,
                                         float value[])
 Working with Fonts
   Font(String fontName, int fontStyle, int pointSize)
Summary : Building a GUI
 Create a container, such as Frame or Applet
 Choose a layout manager
 Create more complex layouts by adding Panels; each
  Panel can have its own layout manager
 Create other components and add them to whichever
  Panels you like
 For each active component, look up what kind of
  Listeners it can have
 Create (implement) the Listeners
   often there is one Listener for each active component
Summary: Building a GUI
 For each Listener you implement, supply the
  methods that it requires
 For Applets, write the necessary HTML
 Graphics
   Drawing Lines
   Drawing Rectangles
   Drawing Ellipse and Circles
   Drawing Polygons
 Color schemes and Fonts
Awt

More Related Content

What's hot (20)

Fragment
Fragment Fragment
Fragment
 
Java swing
Java swingJava swing
Java swing
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Applets
AppletsApplets
Applets
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
C# File IO Operations
C# File IO OperationsC# File IO Operations
C# File IO Operations
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Java interface
Java interfaceJava interface
Java interface
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 

Viewers also liked

Viewers also liked (14)

Bluetooth - Overview
Bluetooth - OverviewBluetooth - Overview
Bluetooth - Overview
 
Bluetooth wi fi wi max 2, 3
Bluetooth wi fi wi max 2, 3Bluetooth wi fi wi max 2, 3
Bluetooth wi fi wi max 2, 3
 
Bluetooth
BluetoothBluetooth
Bluetooth
 
software project management Waterfall model
software project management Waterfall modelsoftware project management Waterfall model
software project management Waterfall model
 
Bluetooth technology
Bluetooth technologyBluetooth technology
Bluetooth technology
 
Visibility control in java
Visibility control in javaVisibility control in java
Visibility control in java
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Wi-Fi vs Bluetooth
Wi-Fi vs BluetoothWi-Fi vs Bluetooth
Wi-Fi vs Bluetooth
 
Waterfall Model
Waterfall ModelWaterfall Model
Waterfall Model
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Waterfall model ppt final
Waterfall model ppt  finalWaterfall model ppt  final
Waterfall model ppt final
 
Waterfall model
Waterfall modelWaterfall model
Waterfall model
 
Wi-Fi Technology
Wi-Fi TechnologyWi-Fi Technology
Wi-Fi Technology
 

Similar to Awt

Similar to Awt (20)

25 awt
25 awt25 awt
25 awt
 
28 awt
28 awt28 awt
28 awt
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
Gui
GuiGui
Gui
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Unit-1 awt advanced java programming
Unit-1 awt advanced java programmingUnit-1 awt advanced java programming
Unit-1 awt advanced java programming
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
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
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Java Applet
Java AppletJava Applet
Java Applet
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Computer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptxComputer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptx
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Awt

  • 1. Rakesh Ravaso Patil Dept. of Computer Engg. T.E. „B‟ 12276
  • 2. Overview…  Introduction to AWT  Swing vs. AWT  Building GUI  Component Hierarchy  AWT Control Fundamentals  Adding Components  Arranging Components  Overview of Event Handling  Working with Graphics  Conclusion
  • 3. AWT (Abstract Window Toolkit)  Present in all Java implementations  Adequate for many applications  Uses the controls defined by your OS  Difficult to build an attractive GUI  import java.awt.*;  import java.awt.event.*;
  • 4. Swing  Same concepts as AWT  Doesn‟t work in ancient Java implementations (Java 1.1 and earlier)  Many more controls, and they are more flexible  Some controls, but not all, are a lot more complicated  Gives a choice of “look and feel” packages  Much easier to build an attractive GUI  import javax.swing.*;
  • 5. Swing vs. AWT  Swing is bigger, slower, and more complicated  But not as slow as it used to be  Swing is more flexible and better looking  Swing and AWT are incompatible--you can use either, but you can‟t mix them  Actually, you can, but it‟s tricky and not worth doing  Learning the AWT is a good start on learning Swing  Many of the most common controls are just renamed  AWT: Button b = new Button ("OK");  Swing: JButton b = new JButton("OK");
  • 6. To build a GUI...  Create some Components, such as buttons, text areas, panels, etc.  Add your Components to your display area  Arrange, or lay out, your Components  Attach Listeners to your Components  Interacting with a Component causes an Event to occur  A Listener gets a message when an interesting event occurs, and executes some code to deal with it
  • 7. An Applet is Panel is Container java.lang.Object | +----java.awt.Component | +----java.awt.Container | +----java.awt.Panel | +----java.applet.Applet …so you can display things in an Applet
  • 8. Example: A "Life" applet Container (Applet) Containers (Panels) Component (Canvas) Components (Buttons) Components (TextFields) Components (Labels)
  • 9. Some types of components Label Button Checkbox Choice Scrollbar TextField List TextArea Button Checkbox CheckboxGroup
  • 10. Creating components  Label lab = new Label ("Hi, Dave!");  Button but = new Button ("Click me!");  Checkbox toggle = new Checkbox ("toggle");  TextField txt = new TextField ("Initial text.", 20);  Scrollbar scrolly = new Scrollbar (Scrollbar.HORIZONTAL, initialValue, bubbleSize, minValue, maxValue);
  • 11. Adding components to the Applet class MyApplet extends Applet { public void init () { add (lab); // same as this.add(lab) add (but); add (toggle); add (txt); add (scrolly); ...
  • 12. Arranging components  Every Container has a layout manager  The default layout for a Panel is FlowLayout  An Applet is a Panel  Therefore, the default layout for a Applet is FlowLayout  You could set it explicitly with setLayout (new FlowLayout( ));  You could change it to some other layout manager
  • 13. Flow Layout  Use add(component); to add to a component when using a FlowLayout  Components are added left-to-right  If no room, a new row is started  Exact layout depends on size of Applet  Components are made as small as possible  FlowLayout is convenient but often ugly
  • 14. BorderLayout  At most five components can be added  If you want more components, add a Panel, then add components to it. •setLayout (new BorderLayout());
  • 15. GridLayout  The GridLayout manager divides the container up into a given number of rows and columns:  new GridLayout(rows, columns) •All sections of the grid are equally sized and as large as possible
  • 16. Making components active  Most components already appear to do something-- buttons click, text appears  To associate an action with a component, attach a listener to it  Components send events, listeners listen for events  Different components may send different events, and require different listeners
  • 17. Listeners  Listeners are interfaces, not classes  class MyButtonListener implements ActionListener {  An interface is a group of methods that must be supplied  When you say implements, you are promising to supply those methods
  • 18. Writing a Listener  For a Button, you need an ActionListener b1.addActionListener (new MyButtonListener ( ));  An ActionListener must have an actionPerformed(ActionEvent) method public void actionPerformed(ActionEvent e) { … }
  • 19. Listeners for TextFields  An ActionListener listens for someone hitting the Enter key  An ActionListener requires this method: public void actionPerformed (ActionEvent e)  You can use getText( ) to get the text  A TextListener listens for any and all keys  A TextListener requires this method: public void textValueChanged(TextEvent e)
  • 20. Working With Graphics Circle Triangle Rounded Rectangle Arc Ellipse Rectangle Lines
  • 21. Working with Graphics  void drawLine(int x1, int y1, int x2, int y2)  void drawRect(int top, int left, int width, int height)  void drawRoundRect(int top, int left,int width, int height, int xDiam, int yDiam)  void drawOvel(int top, int left, int width, int height)  void drawArc(int top, int left, int width,int height, int startAngle, int sweepAngle)  void drawPoly(int x[], int y[], int numPoints)  void fill….
  • 22. Format Shape  Working with colors  HSB  RGB  static int HSBtoRGB(float hue, float saturation, float brightness)  Static float[] RGBtoHSB(int red, int green, int blue, float value[])  Working with Fonts  Font(String fontName, int fontStyle, int pointSize)
  • 23. Summary : Building a GUI  Create a container, such as Frame or Applet  Choose a layout manager  Create more complex layouts by adding Panels; each Panel can have its own layout manager  Create other components and add them to whichever Panels you like  For each active component, look up what kind of Listeners it can have  Create (implement) the Listeners  often there is one Listener for each active component
  • 24. Summary: Building a GUI  For each Listener you implement, supply the methods that it requires  For Applets, write the necessary HTML  Graphics  Drawing Lines  Drawing Rectangles  Drawing Ellipse and Circles  Drawing Polygons  Color schemes and Fonts