SlideShare uma empresa Scribd logo
1 de 44
GUI(Graphical User Interface)
©bilalAmjad
bilalamjad78633@yahoo.com

                                1
An Introduction
• A graphical user interface (GUI) presents a user-friendly
  mechanism for interacting with an application. A GUI
  (pronounced “GOO-ee”) gives an application a distinctive
  “look and feel.” GUIs are built from GUI components. These
  are sometimes called controls or widgets—short for window
  gadgets. A GUI component is an object with which the user
  interacts via the mouse, the keyboard or another form of
  input, such as voice recognition. Java’s so-called Swing GUI
  components from the javax.swing package.



                                                                 2
Simple GUI-Based Input/Output with JOptionPane



                                          Taking Input from User Using
                                          Input Dialog Box




                                                     Converting
                                                     String
                                                     Into integer
                                                     value
                                                                         3


                  Showing Message by Message Dialog Box
Output




         4
Different JoptionPane Message Icons




                                      5
JOptionPane Message Icon (cont)




                                  6
JOptionPane Message Icon (cont)




                                  7
An Overview of SWING components
• Though it’s possible to perform input and output using the
  JOptionPane dialogs, most GUI applications require more elaborate
  user interfaces. Following is the list of some Basic GUI components:




                                                                         8
Swing V/s AWT
• There are actually two sets of GUI components Swing components and AWT
   components.
• In Java’s early days, GUIs were built with components from the Abstract
   Window Toolkit (AWT) inpackage java.awt.
• It Look like the native GUI components of the platform on which a java
   program execute.
For example, a Button object displayed in a Java program running on Microsoft
Windows looks like those in other Windows applications. On Apple Mac OS X,
the Button looks like those in other Mac applications. Sometimes, even the
manner in which a user can interact with an AWT component differs between
platforms. The component’s appearance and the way in which the user
interacts with it are known as its look-and-feel.


                                                                                9
Swing Components
• Swing is the primary Java GUI widget toolkit. It is part of Oracle's
  Java Foundation Classes (JFC) — an API for providing a graphical user
  interface (GUI) for Java programs.
• Swing was developed to provide a more sophisticated set of GUI
  components than the earlier Abstract Window Toolkit (AWT). Swing
  provides a native look and feel that emulates the look and feel of
  several platforms, and also supports a pluggable look and feel that
  allows applications to have a look and feel unrelated to the
  underlying platform. It has more powerful and flexible components
  than AWT. In addition to familiar components such as buttons, check
  box and labels, Swing provides several advanced components such
  as tabbed panel, scroll panes, trees, tables and lists.
• Unlike AWT components, Swing components are not implemented
  by platform-specific code. Instead they are written entirely in Java
  and therefore are platform-independent. The term "lightweight" is
  used to describe such an element.                                       10
Swing Component Example




                          11
Awt components
• The Abstract Window Toolkit (AWT) is Java's original platform-
  independent windowing, graphics, and user-interface widget toolkit.
  The AWT is now part of the Java Foundation Classes (JFC) — the
  standard API for providing a graphical user interface (GUI) for a Java
  program.
• AWT is also the GUI toolkit for a number of Java ME profiles. For
  example, Connected Device Configuration profiles require Java
  runtimes on mobile telephones to support AWT.




                                                                           12
Displaying Text and Images in a window
• Most windows you’ll create that can contain Swing GUI components are instances of
  class JFrame or a subclass of JFrame.
• JFrame is an indirect subclass of class java.awt.Window that provides the basic
  attributes and behaviors of a window—a title bar at the top, and buttons to minimize,
  maximize and close the window.




See the Example Program on the Next
               Slide

                                                                                          13
D                   Importing
I                   Classes
S                   That will be
P                   Used in the
L
                     program
A
Y
I                Declaring three
N                JLabel Instances
G

T
E
X
T
Of the program




A
Constructor




N
D

I
M
A                             14
G
E
S
Output of the Program




                        15
Labeling GUI components
• A typical GUI consists of many components. GUI designers often provide
  text stating the purpose of each. Such text is known as a label and is created
  with a JLabel—a subclass of JComponent.AJLabel displays read-only text, an
  image, or both text and an image. Applications rarely change a label’s
  contents after creating it. Following is the Example program:




                                                                                   16
Output of the program




                        17
Common GUI Event Types and Listener Interfaces
• Following Figure illustrates a hierarchy containing many event
  classes from the package java.awt.event. These event types
  are used with both AWT and Swing components. Additional
  event types that are specific to Swing GUI components are
  declared in package javax.swing.event.




                                                                   18
Jbutton
• A button is a component the user clicks to trigger a specific action.
• A Java application can use several types of buttons, including command
  buttons, checkboxes, toggle buttons and radio buttons.
  Following is the Swing Button Hierarchy:




                                                                           19
JbuttonExample



                 Importing swing and AWT classes

                       ButtonFram class is extending JFrame
                                    Declaring Jbuttons
                                    Variables plainJButton
                                    And fancyJButton


                                          Adds the Jbutton
                                          To JFrame
                                       Creating Image Icon
                                  Adding button to JFrame

                               Creating Button Handler

                                        These lines declares
                                        actionPerformed
                                        To display a message        20
                                        Dialog Box containing the
                                        label for the button
                                        The user pressed
JbuttonExample (cont)



                        Creating
                        Main




                                   21
Buttons that Maintains States
• The Swing GUI components contain three types of state
  buttons
1. JToggleButton
A toggle button is a button that represents a settings with two
states i.e. on and off.
 Toggle buttons look similar to command buttons and display
  a graphic or text (or both) to identify the button.
The graphic or button text should remain the same whether
  the button is in the on or off state.
The state is indicated by highlighting the background of the
  buttons.
 Users can click toggle buttons to turn a setting on or off--for
  instance, to switch between italic and plain style in selected    22
  text.
Button that maintain States (cont)

2-Check Boxes:
A checkbox is a control that represents a setting or value with an on or
 off choice.
The setting of an individual checkbox is independent of other
 checkboxes--that is, more than one checkbox in a set can be checked at
 any given time.
A check mark within the checkbox indicates that the setting is selected.
 The following figure shows both available and unavailable checkboxes in
 selected and unselected states.




                                                                             23
The user clicks a checkbox to switch its setting from off to on, or on to
  off. When a checkbox is unavailable, the user cannot change its setting.
JCheckBoxes Example
Importing the classes




              Using method setFont inherited by
              JtextField indirectly from class
              component

                    Creating two JCheckBox
                    object

                    Creating an instance of class
                    CheckBoxHandler and register
                    It with method addItemListener
                    For both the JCheckBox objects
                                                      24
                    Event Handling is being performed
                    By an instance of private inner class
                    checkboxHandler
JCheckBox Example (Cont)




                           Main Class




                                        25
Buttons that Maintains States(cont)
 3-Radio Buttons
 A radio button represents an exclusive choice within a set of related
  options.
 Within a set of radio buttons, only one button can be on at any given
  time.
 The following figure shows active radio buttons and inactive radio
  buttons in both on and off states.




 When users click a radio button, its setting is always set to on. An
  inner filled circle within the round button graphic indicates that the
  setting is selected. If another button in the set has previously been
  selected, its state changes to off.
                                                                           26
 When a radio button is unavailable, users cannot change its setting.
JRadioButton Example




                 Creating 4 JRadioButtonobjects
                 And adding them to JFrame        27
JRadioButton Example (Cont)          Instantiates ButtonGroup
                                     Object radioGroup
                                  Using ButtonGroup method add
                                  To associate each of the
                                  JRadioButtons with radio group




                         Creating four instances of inner class
                         RadioButtonHandler


                         Class RadioButtonHandler implements
                         Interface ItemListener so it can handle
                         ItemEvents generated by the JRadioButtons



                                                                     28
JRadioButton (cont)




                      29
JComboBox
 A JComboBox, lets the user choose one of several choices, can have two
  very different forms.
 The default form is the uneditable combo box, which features a button and
  a drop-down list of values.




 The second form, called the editable combo box, features a text field with a
  small button abutting it. The user can type a value in the text field or click
  the button to display a drop-down list.



                                                                                   30
JComboBox Example

                                   Declaring and initializing array
                                   Icons with four new image
                                   icon objects
                            It contains the names of the four
                            Image files that are stored in the
                            Same directory as the application


                    A constructor initializes a JComboBox
                    Object with the strings in array names
                    As the elements in the list
                        Using JComboBox method setMaximumRowCount
                        to set Maximum number of elements That are
                        displayed when the user Clicks JComboBox

                      Are one statement that declares the event listner’s 31
                      Class,creates an object of that class and register It as
                      the listener for imagesJComboBox’s ItemEvents.
JComboBoxExample (Cont)




                          32
JList
• A JList presents the user with a group of items, displayed in
  one or more columns, to choose from.
• Lists can have many items, so they are often put in scroll
  panes.
  The following figures shows two applications that use lists.




                                                                  33
Jlist (Cont)
Types of Lists:
 Single Selection
  Only one item can be selected at a time. When the user selects an item, any
  previously selected item is deselected first.




 Single Interval Selection
  Multiple, contiguous items can be selected. When the user begins a new
  selection range, any previously selected items are deselected first.



                                                                                34
Jlist (Cont)
 Multiple Interval Selection:
The default. Any combination of items can be selected. The user must
explicitly deselect items.




                                                                       35
Jlist Example
 Creating Jlist object colorJList

    This line uses Jlist method
    setSelectionMode To specify the list’s
    selection mode.Class ListSelectMode1
    Declares three constants that specify
    A Jlist’s selectionMode-SINGLE SELECTION

Adding new instance of class
JScrollPane to the Jframe.

  These lines uses Jlist method
  addListSelectionListener to register        36
  An object that implements ListSelectionListner
Jlist Example (Cont)




                       37
JSlider
• A JSlider component is intended to let the user easily enter a
  numeric value bounded by a minimum and maximum value.
  The following picture shows an application that uses a slider
  to control animation speed:




                                                                   38
Jslider Example




                    Class OvalPanel contains a paintComponent
                    Method that draws a filled circle.



                   A setDiameter method that changes the
                   Circle’s diameter and repaints the OvalPanel

                  A getPreferredSize method that returns
                  The preferred width and height of an
                  OvalPanel

                   getMinimumSize method that returns
                   An OvalPanel’s minimum width and height
                                                                  39
Jslider Exapmle (Cont)




                         These lines creates Jslider object
                         DiameterSlider to control the diameter
                         Of the circle drawn on the OvalPanel
                            These lines customize the appearance
                            Of the Jslider.Method setMajorTickSpacing
                            Indicates that each major tick mark
                            Represents 10 values in the range of
                            Values supported by the Jslider.
                                                                    40
Jslider Example (Cont)




                         41
Using Frames with Menus
• A menu provides a space-saving way to let the user choose
  one of several options.
• Menus are unique in that, by convention, they aren't placed
  with the other components in the UI. Instead, a menu usually
  appears either in a menu bar or as a popup menu.
• A menu bar contains one or more menus and has a customary,
  platform-dependent location — usually along the top of a
  window.
• A popup menu is a menu that is invisible until the user makes
  a platform-specific mouse action, such as pressing the right
  mouse button, over a popup-enabled component. The popup
  menu then appears under the cursor.                             42
Using Frames with Menus (cont)
• The following figure shows many menu-related components:
  a menu bar, menus, menu items, radio button menu items,
  check box menu items, and separators.




                                                             43
This Was the Introduction to GUI however you can do more and
more with GUI this was just a lecture to tell you about GUI and
                   What you can do with it.

                   That’s All
                Thanks For Your Concentration




                                                                  44

Mais conteúdo relacionado

Mais procurados

GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 
User Interface Design Module 5 screen based controls
User Interface Design Module 5  screen based controlsUser Interface Design Module 5  screen based controls
User Interface Design Module 5 screen based controlsbrindaN
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programmingElizabeth Thomas
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML DiagramsManish Kumar
 
User Interface Design - Module 1 Introduction
User Interface Design - Module 1 IntroductionUser Interface Design - Module 1 Introduction
User Interface Design - Module 1 IntroductionbrindaN
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Elizabeth alexander
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introductionbloodyedge03
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types pptkamal kotecha
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
User Interface Design- Module 3 Menus
User Interface Design- Module 3 MenusUser Interface Design- Module 3 Menus
User Interface Design- Module 3 MenusbrindaN
 

Mais procurados (20)

GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Behavioural modelling
Behavioural modellingBehavioural modelling
Behavioural modelling
 
Java threads
Java threadsJava threads
Java threads
 
UML
UMLUML
UML
 
User Interface Design Module 5 screen based controls
User Interface Design Module 5  screen based controlsUser Interface Design Module 5  screen based controls
User Interface Design Module 5 screen based controls
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Visual Basic Controls ppt
Visual Basic Controls pptVisual Basic Controls ppt
Visual Basic Controls ppt
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Features of java
Features of javaFeatures of java
Features of java
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
User Interface Design - Module 1 Introduction
User Interface Design - Module 1 IntroductionUser Interface Design - Module 1 Introduction
User Interface Design - Module 1 Introduction
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introduction
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Java swing
Java swingJava swing
Java swing
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
User Interface Design- Module 3 Menus
User Interface Design- Module 3 MenusUser Interface Design- Module 3 Menus
User Interface Design- Module 3 Menus
 
Android UI
Android UIAndroid UI
Android UI
 
User interface-design
User interface-designUser interface-design
User interface-design
 

Destaque

Career guidance after bca
Career guidance   after bcaCareer guidance   after bca
Career guidance after bcaJIGAR MAKHIJA
 
INTRODUCTION TO SOFTWARE ENGINEERING
INTRODUCTION TO SOFTWARE ENGINEERINGINTRODUCTION TO SOFTWARE ENGINEERING
INTRODUCTION TO SOFTWARE ENGINEERINGProf Ansari
 
Presentation on bhagat singh
Presentation on bhagat singhPresentation on bhagat singh
Presentation on bhagat singhSarfaraj_alam
 
Graphical user interface of web form
Graphical user interface of web formGraphical user interface of web form
Graphical user interface of web formmentorrbuddy
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface Bivek Pakuwal
 
PThreads Vs Win32 Threads
PThreads  Vs  Win32 ThreadsPThreads  Vs  Win32 Threads
PThreads Vs Win32 ThreadsRobert Sayegh
 
User interfaces presentation
User interfaces presentationUser interfaces presentation
User interfaces presentationsomipam1
 
Introduction To Software Engineering
Introduction To Software EngineeringIntroduction To Software Engineering
Introduction To Software EngineeringLeyla Bonilla
 
human computer interface
human computer interfacehuman computer interface
human computer interfaceSantosh Kumar
 

Destaque (15)

Career guidance after bca
Career guidance   after bcaCareer guidance   after bca
Career guidance after bca
 
Bhagat Singh
Bhagat SinghBhagat Singh
Bhagat Singh
 
An introduction to software engineering
An introduction to software engineeringAn introduction to software engineering
An introduction to software engineering
 
INTRODUCTION TO SOFTWARE ENGINEERING
INTRODUCTION TO SOFTWARE ENGINEERINGINTRODUCTION TO SOFTWARE ENGINEERING
INTRODUCTION TO SOFTWARE ENGINEERING
 
Bhagat Singh
Bhagat SinghBhagat Singh
Bhagat Singh
 
Presentation on bhagat singh
Presentation on bhagat singhPresentation on bhagat singh
Presentation on bhagat singh
 
Matlab GUI
Matlab GUIMatlab GUI
Matlab GUI
 
Graphical user interface of web form
Graphical user interface of web formGraphical user interface of web form
Graphical user interface of web form
 
Matlab GUI
Matlab GUIMatlab GUI
Matlab GUI
 
Graphical User Interface
Graphical User Interface Graphical User Interface
Graphical User Interface
 
Gui
GuiGui
Gui
 
PThreads Vs Win32 Threads
PThreads  Vs  Win32 ThreadsPThreads  Vs  Win32 Threads
PThreads Vs Win32 Threads
 
User interfaces presentation
User interfaces presentationUser interfaces presentation
User interfaces presentation
 
Introduction To Software Engineering
Introduction To Software EngineeringIntroduction To Software Engineering
Introduction To Software Engineering
 
human computer interface
human computer interfacehuman computer interface
human computer interface
 

Semelhante a Graphical User Interface (Gui)

Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxTadeseBeyene
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892renuka gavli
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in javaAdil Mehmoood
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02Ankit Dubey
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTSbharathiv53
 
Python - gui programming (tkinter)
Python - gui programming (tkinter)Python - gui programming (tkinter)
Python - gui programming (tkinter)Learnbay Datascience
 
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.pptxjonathancapitulo2
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1sotlsoc
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)Narayana Swamy
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01Ankit Dubey
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01JONDHLEPOLY
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awtvishal choudhary
 
Chapter11 graphical components
Chapter11 graphical componentsChapter11 graphical components
Chapter11 graphical componentsArifa Fatima
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating guiViên Mai
 

Semelhante a Graphical User Interface (Gui) (20)

GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
 
SWING USING JAVA WITH VARIOUS COMPONENTS
SWING USING  JAVA WITH VARIOUS COMPONENTSSWING USING  JAVA WITH VARIOUS COMPONENTS
SWING USING JAVA WITH VARIOUS COMPONENTS
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Python - gui programming (tkinter)
Python - gui programming (tkinter)Python - gui programming (tkinter)
Python - gui programming (tkinter)
 
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
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
Chapter11 graphical components
Chapter11 graphical componentsChapter11 graphical components
Chapter11 graphical components
 
Slot04 creating gui
Slot04 creating guiSlot04 creating gui
Slot04 creating gui
 

Mais de Bilal Amjad

Introduction to management
Introduction to managementIntroduction to management
Introduction to managementBilal Amjad
 
Organizational structure
Organizational structureOrganizational structure
Organizational structureBilal Amjad
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modesBilal Amjad
 
Communication process (effective)
Communication process (effective)Communication process (effective)
Communication process (effective)Bilal Amjad
 
Ethnic Diversity in Punjab
Ethnic Diversity in PunjabEthnic Diversity in Punjab
Ethnic Diversity in PunjabBilal Amjad
 
Social Networking
Social NetworkingSocial Networking
Social NetworkingBilal Amjad
 

Mais de Bilal Amjad (7)

Introduction to management
Introduction to managementIntroduction to management
Introduction to management
 
Organizational structure
Organizational structureOrganizational structure
Organizational structure
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Communication process (effective)
Communication process (effective)Communication process (effective)
Communication process (effective)
 
Set Operations
Set OperationsSet Operations
Set Operations
 
Ethnic Diversity in Punjab
Ethnic Diversity in PunjabEthnic Diversity in Punjab
Ethnic Diversity in Punjab
 
Social Networking
Social NetworkingSocial Networking
Social Networking
 

Último

Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 

Último (20)

Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 

Graphical User Interface (Gui)

  • 2. An Introduction • A graphical user interface (GUI) presents a user-friendly mechanism for interacting with an application. A GUI (pronounced “GOO-ee”) gives an application a distinctive “look and feel.” GUIs are built from GUI components. These are sometimes called controls or widgets—short for window gadgets. A GUI component is an object with which the user interacts via the mouse, the keyboard or another form of input, such as voice recognition. Java’s so-called Swing GUI components from the javax.swing package. 2
  • 3. Simple GUI-Based Input/Output with JOptionPane Taking Input from User Using Input Dialog Box Converting String Into integer value 3 Showing Message by Message Dialog Box
  • 4. Output 4
  • 8. An Overview of SWING components • Though it’s possible to perform input and output using the JOptionPane dialogs, most GUI applications require more elaborate user interfaces. Following is the list of some Basic GUI components: 8
  • 9. Swing V/s AWT • There are actually two sets of GUI components Swing components and AWT components. • In Java’s early days, GUIs were built with components from the Abstract Window Toolkit (AWT) inpackage java.awt. • It Look like the native GUI components of the platform on which a java program execute. For example, a Button object displayed in a Java program running on Microsoft Windows looks like those in other Windows applications. On Apple Mac OS X, the Button looks like those in other Mac applications. Sometimes, even the manner in which a user can interact with an AWT component differs between platforms. The component’s appearance and the way in which the user interacts with it are known as its look-and-feel. 9
  • 10. Swing Components • Swing is the primary Java GUI widget toolkit. It is part of Oracle's Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs. • Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT). Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform. It has more powerful and flexible components than AWT. In addition to familiar components such as buttons, check box and labels, Swing provides several advanced components such as tabbed panel, scroll panes, trees, tables and lists. • Unlike AWT components, Swing components are not implemented by platform-specific code. Instead they are written entirely in Java and therefore are platform-independent. The term "lightweight" is used to describe such an element. 10
  • 12. Awt components • The Abstract Window Toolkit (AWT) is Java's original platform- independent windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program. • AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support AWT. 12
  • 13. Displaying Text and Images in a window • Most windows you’ll create that can contain Swing GUI components are instances of class JFrame or a subclass of JFrame. • JFrame is an indirect subclass of class java.awt.Window that provides the basic attributes and behaviors of a window—a title bar at the top, and buttons to minimize, maximize and close the window. See the Example Program on the Next Slide 13
  • 14. D Importing I Classes S That will be P Used in the L program A Y I Declaring three N JLabel Instances G T E X T Of the program A Constructor N D I M A 14 G E S
  • 15. Output of the Program 15
  • 16. Labeling GUI components • A typical GUI consists of many components. GUI designers often provide text stating the purpose of each. Such text is known as a label and is created with a JLabel—a subclass of JComponent.AJLabel displays read-only text, an image, or both text and an image. Applications rarely change a label’s contents after creating it. Following is the Example program: 16
  • 17. Output of the program 17
  • 18. Common GUI Event Types and Listener Interfaces • Following Figure illustrates a hierarchy containing many event classes from the package java.awt.event. These event types are used with both AWT and Swing components. Additional event types that are specific to Swing GUI components are declared in package javax.swing.event. 18
  • 19. Jbutton • A button is a component the user clicks to trigger a specific action. • A Java application can use several types of buttons, including command buttons, checkboxes, toggle buttons and radio buttons. Following is the Swing Button Hierarchy: 19
  • 20. JbuttonExample Importing swing and AWT classes ButtonFram class is extending JFrame Declaring Jbuttons Variables plainJButton And fancyJButton Adds the Jbutton To JFrame Creating Image Icon Adding button to JFrame Creating Button Handler These lines declares actionPerformed To display a message 20 Dialog Box containing the label for the button The user pressed
  • 21. JbuttonExample (cont) Creating Main 21
  • 22. Buttons that Maintains States • The Swing GUI components contain three types of state buttons 1. JToggleButton A toggle button is a button that represents a settings with two states i.e. on and off.  Toggle buttons look similar to command buttons and display a graphic or text (or both) to identify the button. The graphic or button text should remain the same whether the button is in the on or off state. The state is indicated by highlighting the background of the buttons.  Users can click toggle buttons to turn a setting on or off--for instance, to switch between italic and plain style in selected 22 text.
  • 23. Button that maintain States (cont) 2-Check Boxes: A checkbox is a control that represents a setting or value with an on or off choice. The setting of an individual checkbox is independent of other checkboxes--that is, more than one checkbox in a set can be checked at any given time. A check mark within the checkbox indicates that the setting is selected. The following figure shows both available and unavailable checkboxes in selected and unselected states.  23 The user clicks a checkbox to switch its setting from off to on, or on to off. When a checkbox is unavailable, the user cannot change its setting.
  • 24. JCheckBoxes Example Importing the classes Using method setFont inherited by JtextField indirectly from class component Creating two JCheckBox object Creating an instance of class CheckBoxHandler and register It with method addItemListener For both the JCheckBox objects 24 Event Handling is being performed By an instance of private inner class checkboxHandler
  • 25. JCheckBox Example (Cont) Main Class 25
  • 26. Buttons that Maintains States(cont) 3-Radio Buttons A radio button represents an exclusive choice within a set of related options. Within a set of radio buttons, only one button can be on at any given time. The following figure shows active radio buttons and inactive radio buttons in both on and off states. When users click a radio button, its setting is always set to on. An inner filled circle within the round button graphic indicates that the setting is selected. If another button in the set has previously been selected, its state changes to off. 26 When a radio button is unavailable, users cannot change its setting.
  • 27. JRadioButton Example Creating 4 JRadioButtonobjects And adding them to JFrame 27
  • 28. JRadioButton Example (Cont) Instantiates ButtonGroup Object radioGroup Using ButtonGroup method add To associate each of the JRadioButtons with radio group Creating four instances of inner class RadioButtonHandler Class RadioButtonHandler implements Interface ItemListener so it can handle ItemEvents generated by the JRadioButtons 28
  • 30. JComboBox  A JComboBox, lets the user choose one of several choices, can have two very different forms.  The default form is the uneditable combo box, which features a button and a drop-down list of values.  The second form, called the editable combo box, features a text field with a small button abutting it. The user can type a value in the text field or click the button to display a drop-down list. 30
  • 31. JComboBox Example Declaring and initializing array Icons with four new image icon objects It contains the names of the four Image files that are stored in the Same directory as the application A constructor initializes a JComboBox Object with the strings in array names As the elements in the list Using JComboBox method setMaximumRowCount to set Maximum number of elements That are displayed when the user Clicks JComboBox Are one statement that declares the event listner’s 31 Class,creates an object of that class and register It as the listener for imagesJComboBox’s ItemEvents.
  • 33. JList • A JList presents the user with a group of items, displayed in one or more columns, to choose from. • Lists can have many items, so they are often put in scroll panes. The following figures shows two applications that use lists. 33
  • 34. Jlist (Cont) Types of Lists:  Single Selection Only one item can be selected at a time. When the user selects an item, any previously selected item is deselected first.  Single Interval Selection Multiple, contiguous items can be selected. When the user begins a new selection range, any previously selected items are deselected first. 34
  • 35. Jlist (Cont)  Multiple Interval Selection: The default. Any combination of items can be selected. The user must explicitly deselect items. 35
  • 36. Jlist Example Creating Jlist object colorJList This line uses Jlist method setSelectionMode To specify the list’s selection mode.Class ListSelectMode1 Declares three constants that specify A Jlist’s selectionMode-SINGLE SELECTION Adding new instance of class JScrollPane to the Jframe. These lines uses Jlist method addListSelectionListener to register 36 An object that implements ListSelectionListner
  • 38. JSlider • A JSlider component is intended to let the user easily enter a numeric value bounded by a minimum and maximum value. The following picture shows an application that uses a slider to control animation speed: 38
  • 39. Jslider Example Class OvalPanel contains a paintComponent Method that draws a filled circle. A setDiameter method that changes the Circle’s diameter and repaints the OvalPanel A getPreferredSize method that returns The preferred width and height of an OvalPanel getMinimumSize method that returns An OvalPanel’s minimum width and height 39
  • 40. Jslider Exapmle (Cont) These lines creates Jslider object DiameterSlider to control the diameter Of the circle drawn on the OvalPanel These lines customize the appearance Of the Jslider.Method setMajorTickSpacing Indicates that each major tick mark Represents 10 values in the range of Values supported by the Jslider. 40
  • 42. Using Frames with Menus • A menu provides a space-saving way to let the user choose one of several options. • Menus are unique in that, by convention, they aren't placed with the other components in the UI. Instead, a menu usually appears either in a menu bar or as a popup menu. • A menu bar contains one or more menus and has a customary, platform-dependent location — usually along the top of a window. • A popup menu is a menu that is invisible until the user makes a platform-specific mouse action, such as pressing the right mouse button, over a popup-enabled component. The popup menu then appears under the cursor. 42
  • 43. Using Frames with Menus (cont) • The following figure shows many menu-related components: a menu bar, menus, menu items, radio button menu items, check box menu items, and separators. 43
  • 44. This Was the Introduction to GUI however you can do more and more with GUI this was just a lecture to tell you about GUI and What you can do with it. That’s All Thanks For Your Concentration 44