KEMBAR78
Chapter One Java Swings GUA programming.ppt
Basics of GUI Programming
Chapter One
Java Swings
What is GUI?
 A graphical user interface (GUI) is a type of user
interface item that allows people to interact with
programs as a clicking instead of a dull console
interface.
 A GUI (pronounced “GOO-ee”) gives an application
a distinctive “look” and “feel.” Providing different
applications with consistent, intuitive user interface
components allows users to be somewhat familiar
with an application, so that they can learn it more
quickly and use it more productively.
GUI Components
 GUIs are built from GUI components.
 GUI component is an object with which the
user interacts via---
– Mouse
– Keyboard
– Voice
– Etc;
GUI Components
 Two sets of GUI components in Java
– Swing (in package javax.swing)
– AWT ( in package java.awt)
 AWT
– AWT is the standard abbreviation for Abstract Window Toolkit. It is
a platform-dependent API for developing GUI (Graphical User
Interface) or window-based applications using Java. It was devised
by Sun Microsystems in 1995
– It is a heavy-weight API as it is usually generated by the system’s
host operating system. It comes with a significantly high number of
classes and methods, primarily created for designing and managing
GUI.
GUI Components
 Swing
- Swing components are less dependent on the target
platform and use less of the native GUI resource.
For this reason, Swing components that don’t rely on
native GUI are referred to as lightweight
components.
Classification of GUI classes
 Container classes
 Component classes
 Helper classes
Container Classes
 Component classes that are used as containers to
contain other GUI components
– JFrame
 Window not contained inside another window
 Container that holds other Swing components
 JFrame object is a window – has a border, sizing buttons
– JPanel
 Invisible container that holds user-interface components
 Can be used as a canvas to draw graphics
 Can be nested
MyFrame output
GUI Component Classes
 JButton
 JTextField
 JTextArea
 JComboBox
 JList
 JRadioButton
 JMenu
GUI Helper Classes
 Used by components and containers to draw
and place objects
– Graphics
 Abstract class for drawing strings, lines and simple
shapes
– Color
 Specifies colors of GUI components
– Font
 Specifies fonts for the text and drawings on GUI
components
GUI Helper Classes
 LayoutManager
– Interface that specifies how components are
arranged in a container
Layout Managers
 Java GUI components are placed in
containers, where they are arranged by the
container’s layout manager.
 Layout manager places components in the
correct locations in the containers
Layout Managers - Examples
 FlowLayout – simplest layout manager
– Components are arranged in the container from
left to right, top to bottom in the order in which
they were added
– Default manager
 BorderLayout
– Has 5 regions NORTH (top), SOUTH (bottom),
EAST (right side), WEST (left side) and CENTER
JFrame methods
To create a user interface, you need to create
either a frame hold user-interface
components.
 JFrame() – constructs an untitled JFrame
object
 JFrame(String ) – constructs a JFrame object
with the specified title
THE END
ANY QUESTION
THANK YOU

Chapter One Java Swings GUA programming.ppt

  • 1.
    Basics of GUIProgramming Chapter One Java Swings
  • 2.
    What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs as a clicking instead of a dull console interface.  A GUI (pronounced “GOO-ee”) gives an application a distinctive “look” and “feel.” Providing different applications with consistent, intuitive user interface components allows users to be somewhat familiar with an application, so that they can learn it more quickly and use it more productively.
  • 3.
    GUI Components  GUIsare built from GUI components.  GUI component is an object with which the user interacts via--- – Mouse – Keyboard – Voice – Etc;
  • 4.
    GUI Components  Twosets of GUI components in Java – Swing (in package javax.swing) – AWT ( in package java.awt)  AWT – AWT is the standard abbreviation for Abstract Window Toolkit. It is a platform-dependent API for developing GUI (Graphical User Interface) or window-based applications using Java. It was devised by Sun Microsystems in 1995 – It is a heavy-weight API as it is usually generated by the system’s host operating system. It comes with a significantly high number of classes and methods, primarily created for designing and managing GUI.
  • 5.
    GUI Components  Swing -Swing components are less dependent on the target platform and use less of the native GUI resource. For this reason, Swing components that don’t rely on native GUI are referred to as lightweight components.
  • 6.
    Classification of GUIclasses  Container classes  Component classes  Helper classes
  • 7.
    Container Classes  Componentclasses that are used as containers to contain other GUI components – JFrame  Window not contained inside another window  Container that holds other Swing components  JFrame object is a window – has a border, sizing buttons – JPanel  Invisible container that holds user-interface components  Can be used as a canvas to draw graphics  Can be nested
  • 8.
  • 9.
    GUI Component Classes JButton  JTextField  JTextArea  JComboBox  JList  JRadioButton  JMenu
  • 10.
    GUI Helper Classes Used by components and containers to draw and place objects – Graphics  Abstract class for drawing strings, lines and simple shapes – Color  Specifies colors of GUI components – Font  Specifies fonts for the text and drawings on GUI components
  • 11.
    GUI Helper Classes LayoutManager – Interface that specifies how components are arranged in a container
  • 12.
    Layout Managers  JavaGUI components are placed in containers, where they are arranged by the container’s layout manager.  Layout manager places components in the correct locations in the containers
  • 13.
    Layout Managers -Examples  FlowLayout – simplest layout manager – Components are arranged in the container from left to right, top to bottom in the order in which they were added – Default manager  BorderLayout – Has 5 regions NORTH (top), SOUTH (bottom), EAST (right side), WEST (left side) and CENTER
  • 14.
    JFrame methods To createa user interface, you need to create either a frame hold user-interface components.  JFrame() – constructs an untitled JFrame object  JFrame(String ) – constructs a JFrame object with the specified title
  • 15.