SlideShare ist ein Scribd-Unternehmen logo
1 von 26
GUI
 A graphical user interface (GUI) presents a pictorial
interface to a program, GUI's allow the user to work in a
more productive manner.
 A GUI component is an object with which the user
interacts via the mouse or keyboard, below are some of
the Java GUI components
 Some of the basic GUI components are
 JLabelAn area where uneditable text or icons can be displayed
 JTextFieldAn area where the user inputs data from the keyboard,
this area can also display data
 JButtonAn area that triggers an event when clicked
 JCheckBoxA GUI component that is either selected or not
selected
 JComboBoxA drop-down list of items from which the user can
make a selection by clicking an item in the list or typing into the box
 JListAn area where a list of items is displayed from which the user
can make a selection by clicking once on any element in the list.
Double-clicking an element in the list generates an action event,
Multiple elements can be selected
 JPanelA container in which components can be placed
Java Layout Managers
 The GUI is made up of a number of components, the
Layout Managers affect the content pane.
 Layout Managers are provided to arrange GUI
components on a container for presentation purposes.
This allows the programmer to concentrate on the basic
"look and feel" and lets the layout managers process
most of the layout details
 Several AWT and Swing classes provide layout managers
for general use:
1. BorderLayout
2. BoxLayout
3. CardLayout
4. FlowLayout
5. GridBagLayout
6. GridLayout
7. GroupLayout
8. SpringLayout
Here are 5 of the layout managers.
BorderLayout
 The class BorderLayout arranges the components to fit
in the five regions: east, west, north, south and center.
Each region is can contain only one component and each
component in each region is identified by the
corresponding constant NORTH, SOUTH, EAST, WEST,
and CENTER.
 Class declaration
 Following is the declaration
for java.awt.BorderLayout class:
 public class BorderLayout extends Object implements
LayoutManager2, Serializable
 Here are the constructors defined by BorderLayout:
1. BorderLayout()
2. BorderLayout(int horz, int vert)
the first form creates a default border layout. The second
allows you to specify the horizontal and vertical space left
between components in horz and vert, respectively.
BorderLayout defines the following constants that specify
the regions.
BorderLayout.CENTER, BorderLayout.SOUTH,
BorderLayout.EAST, BorderLayout.WEST,
BorderLayout.NORTH
CardLayout
 The class CardLayout arranges each component in the
container as a card. Only one card is visible at a time, and
the container acts as a stack of cards.
 Class declaration
 Following is the declaration
for java.awt.CardLayout class:
 public class CardLayout extends Object implements
LayoutManager2, Serializable
 CardLayout provides these two constructors:
1. CardLayout()
2. CardLayout(int horz, int vert)
FlowLayout 
 The class FlowLayout components in a left-to-right
flow.
 This is the most basic layout manager, components are
placed from left to right as they were added, when the
edge is reached the components are put on the next line.
You can align the components left, right or center
(default).
 Class declaration
 Following is the declaration
for java.awt.FlowLayout class:
 public class FlowLayout extends Object implements
LayoutManager, Serializable
 Here are the constructors for FlowLayout:
1. FlowLayout()
2. FlowLayout(int how)
3. FlowLayout(int how, int horz, int vert)
The first form creates the default layout, which centers
components and leaves five pixels of space between each
component. The second form lets you specify how each
line is aligned. Valid values of how are as follows:
FlowLayout.LEFT
FlowLayout.CENTER
FlowLayout.RIGHT
GridLayout 
 Introduction
 The class GridLayout arranges components in a
rectangular grid.
 Class declaration
 Following is the declaration
for java.awt.GridLayout class:
 public class GridLayout extends Object implements
LayoutManager, Serializable
 GridLayout are shown here:
1. GridLayout()
2. GridLayout(int numRows, int numColumns)
3. GridLayout(int numRows, int numColumns, int horz, int
vert)
GridBagLayout 
 The class GridBagLayout arranges components in a
horizontal and vertical manner.
 Class declaration
 Following is the declaration
for java.awt.GridBagLayout class:
 public class GridBagLayout extends Object implements
LayoutManager2, Serializable
GroupLayout 
 GroupLayout is a layout manager that was developed for use
by GUI builder tools, but it can also be used
manually. GroupLayout works with the horizontal and vertical
layouts separately. The layout is defined for each dimension
independently. Consequently, however, each component
needs to be defined twice in the layout. The Find window
shown above is an example of a GroupLayout. .
 Class declaration
 Following is the declaration
for javax.swing.GroupLayout class:
 public class GroupLayout extends Object implements
LayoutManager2
SpringLayout
 SpringLayout is a flexible layout manager designed for use by
GUI builders. It lets you specify precise relationships between
the edges of components under its control. For example, you
might define that the left edge of one component is a certain
distance (which can be dynamically calculated) from the right
edge of a second component.SpringLayout lays out the
children of its associated container according to a set of
constraints, as shall be seen in
 Class declaration
 Following is the declaration
for javax.swing.SpringLayout class:
 public class SpringLayout extends Object implements
LayoutManager2
Graphical User Interface in JAVA
Graphical User Interface in JAVA

Weitere ähnliche Inhalte

Was ist angesagt?

Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
Prabhdeep Singh
 
GUI Programming using NetBeans (1).pptx
GUI Programming using NetBeans (1).pptxGUI Programming using NetBeans (1).pptx
GUI Programming using NetBeans (1).pptx
Sumalee Sonamthiang
 

Was ist angesagt? (20)

Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Graphical User Interface (Gui)
Graphical User Interface (Gui)Graphical User Interface (Gui)
Graphical User Interface (Gui)
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
 
Visual basic
Visual basicVisual basic
Visual basic
 
Android intents
Android intentsAndroid intents
Android intents
 
Android UI
Android UIAndroid UI
Android UI
 
Fragment
Fragment Fragment
Fragment
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Java applets
Java appletsJava applets
Java applets
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
GUI Programming using NetBeans (1).pptx
GUI Programming using NetBeans (1).pptxGUI Programming using NetBeans (1).pptx
GUI Programming using NetBeans (1).pptx
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Java swing
Java swingJava swing
Java swing
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 
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 form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
Java swing
Java swingJava swing
Java swing
 
Event handling
Event handlingEvent handling
Event handling
 

Ähnlich wie Graphical User Interface in JAVA

java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
ssuserec53e73
 
Java gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docxJava gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docx
olsenlinnea427
 
Text Component FeaturesThe JTextComponent class is the foundation .pdf
Text Component FeaturesThe JTextComponent class is the foundation .pdfText Component FeaturesThe JTextComponent class is the foundation .pdf
Text Component FeaturesThe JTextComponent class is the foundation .pdf
aquadreammail
 
Layout managementand event handling
Layout managementand event handlingLayout managementand event handling
Layout managementand event handling
Charli Patel
 
View groups containers
View groups containersView groups containers
View groups containers
Mani Selvaraj
 

Ähnlich wie Graphical User Interface in JAVA (20)

Java
JavaJava
Java
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
 
java swing
java swingjava swing
java swing
 
Swing
SwingSwing
Swing
 
Java gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docxJava gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docx
 
Layout manager
Layout managerLayout manager
Layout manager
 
14a-gui.ppt
14a-gui.ppt14a-gui.ppt
14a-gui.ppt
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
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
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 
swingbasics
swingbasicsswingbasics
swingbasics
 
Module 2
Module 2Module 2
Module 2
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
 
Text Component FeaturesThe JTextComponent class is the foundation .pdf
Text Component FeaturesThe JTextComponent class is the foundation .pdfText Component FeaturesThe JTextComponent class is the foundation .pdf
Text Component FeaturesThe JTextComponent class is the foundation .pdf
 
Layout managementand event handling
Layout managementand event handlingLayout managementand event handling
Layout managementand event handling
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
View groups containers
View groups containersView groups containers
View groups containers
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 

Mehr von suraj pandey

Mehr von suraj pandey (20)

Systemcare in computer
Systemcare in computer Systemcare in computer
Systemcare in computer
 
vb.net Constructor and destructor
vb.net Constructor and destructorvb.net Constructor and destructor
vb.net Constructor and destructor
 
Overloading and overriding in vb.net
Overloading and overriding in vb.netOverloading and overriding in vb.net
Overloading and overriding in vb.net
 
Basic in Computernetwork
Basic in ComputernetworkBasic in Computernetwork
Basic in Computernetwork
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
 
Dos commands new
Dos commands new Dos commands new
Dos commands new
 
History of computer
History of computerHistory of computer
History of computer
 
Dos commands
Dos commandsDos commands
Dos commands
 
Basic of Internet&email
Basic of Internet&emailBasic of Internet&email
Basic of Internet&email
 
Basic fundamental Computer input/output Accessories
Basic fundamental Computer input/output AccessoriesBasic fundamental Computer input/output Accessories
Basic fundamental Computer input/output Accessories
 
Introduction of exception in vb.net
Introduction of exception in vb.netIntroduction of exception in vb.net
Introduction of exception in vb.net
 
Transmission mediums in computer networks
Transmission mediums in computer networksTransmission mediums in computer networks
Transmission mediums in computer networks
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
 
Computer Fundamental Network topologies
Computer Fundamental Network topologiesComputer Fundamental Network topologies
Computer Fundamental Network topologies
 
Basic of Computer software
Basic of Computer softwareBasic of Computer software
Basic of Computer software
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Generics in java
Generics in javaGenerics in java
Generics in java
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Kürzlich hochgeladen (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

Graphical User Interface in JAVA

  • 1. GUI
  • 2.  A graphical user interface (GUI) presents a pictorial interface to a program, GUI's allow the user to work in a more productive manner.  A GUI component is an object with which the user interacts via the mouse or keyboard, below are some of the Java GUI components
  • 3.
  • 4.  Some of the basic GUI components are  JLabelAn area where uneditable text or icons can be displayed  JTextFieldAn area where the user inputs data from the keyboard, this area can also display data  JButtonAn area that triggers an event when clicked  JCheckBoxA GUI component that is either selected or not selected  JComboBoxA drop-down list of items from which the user can make a selection by clicking an item in the list or typing into the box  JListAn area where a list of items is displayed from which the user can make a selection by clicking once on any element in the list. Double-clicking an element in the list generates an action event, Multiple elements can be selected  JPanelA container in which components can be placed
  • 5. Java Layout Managers  The GUI is made up of a number of components, the Layout Managers affect the content pane.  Layout Managers are provided to arrange GUI components on a container for presentation purposes. This allows the programmer to concentrate on the basic "look and feel" and lets the layout managers process most of the layout details
  • 6.
  • 7.  Several AWT and Swing classes provide layout managers for general use: 1. BorderLayout 2. BoxLayout 3. CardLayout 4. FlowLayout 5. GridBagLayout 6. GridLayout 7. GroupLayout 8. SpringLayout
  • 8. Here are 5 of the layout managers.
  • 9. BorderLayout  The class BorderLayout arranges the components to fit in the five regions: east, west, north, south and center. Each region is can contain only one component and each component in each region is identified by the corresponding constant NORTH, SOUTH, EAST, WEST, and CENTER.  Class declaration  Following is the declaration for java.awt.BorderLayout class:  public class BorderLayout extends Object implements LayoutManager2, Serializable
  • 10.  Here are the constructors defined by BorderLayout: 1. BorderLayout() 2. BorderLayout(int horz, int vert) the first form creates a default border layout. The second allows you to specify the horizontal and vertical space left between components in horz and vert, respectively. BorderLayout defines the following constants that specify the regions. BorderLayout.CENTER, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, BorderLayout.NORTH
  • 11.
  • 12. CardLayout  The class CardLayout arranges each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards.  Class declaration  Following is the declaration for java.awt.CardLayout class:  public class CardLayout extends Object implements LayoutManager2, Serializable
  • 13.  CardLayout provides these two constructors: 1. CardLayout() 2. CardLayout(int horz, int vert)
  • 14.
  • 15. FlowLayout   The class FlowLayout components in a left-to-right flow.  This is the most basic layout manager, components are placed from left to right as they were added, when the edge is reached the components are put on the next line. You can align the components left, right or center (default).  Class declaration  Following is the declaration for java.awt.FlowLayout class:  public class FlowLayout extends Object implements LayoutManager, Serializable
  • 16.  Here are the constructors for FlowLayout: 1. FlowLayout() 2. FlowLayout(int how) 3. FlowLayout(int how, int horz, int vert) The first form creates the default layout, which centers components and leaves five pixels of space between each component. The second form lets you specify how each line is aligned. Valid values of how are as follows: FlowLayout.LEFT FlowLayout.CENTER FlowLayout.RIGHT
  • 17.
  • 18. GridLayout   Introduction  The class GridLayout arranges components in a rectangular grid.  Class declaration  Following is the declaration for java.awt.GridLayout class:  public class GridLayout extends Object implements LayoutManager, Serializable
  • 19.  GridLayout are shown here: 1. GridLayout() 2. GridLayout(int numRows, int numColumns) 3. GridLayout(int numRows, int numColumns, int horz, int vert)
  • 20. GridBagLayout   The class GridBagLayout arranges components in a horizontal and vertical manner.  Class declaration  Following is the declaration for java.awt.GridBagLayout class:  public class GridBagLayout extends Object implements LayoutManager2, Serializable
  • 21.
  • 22. GroupLayout   GroupLayout is a layout manager that was developed for use by GUI builder tools, but it can also be used manually. GroupLayout works with the horizontal and vertical layouts separately. The layout is defined for each dimension independently. Consequently, however, each component needs to be defined twice in the layout. The Find window shown above is an example of a GroupLayout. .  Class declaration  Following is the declaration for javax.swing.GroupLayout class:  public class GroupLayout extends Object implements LayoutManager2
  • 23.
  • 24. SpringLayout  SpringLayout is a flexible layout manager designed for use by GUI builders. It lets you specify precise relationships between the edges of components under its control. For example, you might define that the left edge of one component is a certain distance (which can be dynamically calculated) from the right edge of a second component.SpringLayout lays out the children of its associated container according to a set of constraints, as shall be seen in  Class declaration  Following is the declaration for javax.swing.SpringLayout class:  public class SpringLayout extends Object implements LayoutManager2