SlideShare a Scribd company logo
1 of 69
Download to read offline
Advanced Java Programming
by
Amol S. Gaikwad
Lecturer,
Government Polytechnic Gadchiroli
Advanced Java Programming
Unit-I
Abstract Windowing
Toolkit (AWT)
Welcome!
Are you excited for a fun
learning session?
Unit Outcomes
Develop Graphical User (GUI) programs using AWT
Components for given component
Create frame window with specified AWT
components
Develop programs using menu and Dialog Boxes for the given
Arrange the GUI components using specified AWT
components
What is AWT ?
Abstract Window Toolkit (AWT) is one of java's largest packages
AWT containes many classess and methods
We can create user interface with AWT.
AWT classes are present in java.awt package
AWT is use to create and manage windows
Windows Fundamentals
Component class
Container class
Window class
Panel class
Frame class
Fig 1.1 The class hierarchy of Panel and Frame
Component object remembers
foreground,background, text font
Component
Class
Top of AWT heirarchy All UI elements are
subclass of this class
Has 100 public methods
Manages events such as
mouse and keyboard i/p
Container
Class
This class is sublcass of
Component class
Has methods Component
objects to be nested
within it.
This class is responsible for
laying out components
Other conatiner objects
can be stored inside of a
container
It uses various layout managers
Panel Class
This class is sublcass of
Container class
No new methods, simply
implements Container
Applet output is drawn on
surface of Panel object
Panel is superclass for
Applet
Other components can be added to a
Panel object by its add( ) method
Panel window doesn't contain title bar,
menu bar, or border
Window Class
This class creates a top
level window
A top level window is not
contained in any other
object
It directly sits on desktop
Generally we don't create
Window object directly
Instead we use sublcass of Window called Frame
Canvas Class
Canvas is a not a part of
heirarchy
Canvas is a blank window on
which you can draw
It is other type of window
Creating Frame windows
Setting window's dimensions
Frame( )
Frame( String title)
Frame class constructors
void setSize(int newWidth, int newHeight)
void setSize(Dimension newSize)
Dimension getSize( )
Creating Frame windows
Setting a window's title
void setVisible(boolean visibleFlag)
Hiding and showing a window
void setTitle(String newTitle)
setVisible(false)
windowClosing( )
Closing a Frame window
Output of Frame window
Applet window Frame window
Sample AWT Application
AWT Application
AWT controls and layout managers
Controls are components that allows to interact with the
application
Layout managers automatically positions components
within a container
Menu bar creates a drop down menus of options from
which we can select options
AWT controls List
AWT supports following types of controls
Labels
Push buttons
Check boxes
Choice list
Lists
Scroll bars
Text Editing
AWT controls
Label
TextField
TextArea
Button
CheckBox
CheckBoxGroup
Choice
Labels
A label is an object of class/type Label
It contains a string displayed on screen
It is passive control and doesn't support any interaction
Constructors of Label class
Label( ) throws HeadlessException
Label(String str) throws HeadlessException
Label(String str, int how) throws HeadlessException
Functions & Example of Labels
void setText(String str)
String getText( )
void setAlignment(int how)
void setAlignment(int how)
int getAlignment( )
Buttons
A push button is an object of class/type Button
A push button contains a label
It can be pressed to generate event
Button( ) throws HeadlessException
Button(String str) throws HeadlessException
void setLabel(String str)
String getLabel( )
Example of Buttons
Checkbox
A checkbox is an object of class/type Checkbox
It has a small box which can be checked
Checkbox has label
It's state can be changed by clicking it
Check boxes can be used individually or part of a group
Constructors of Checkbox
Checkbox( ) throws HeadlessException
Checkbox(String str) throws HeadlessException
Checkbox(String str, boolean on) throws HeadlessException
Checkbox(String str, boolean on, CheckboxGroup cbGroup) throws
HeadlessException
Checkbox(String str, CheckboxGroup cbGroup, boolean on)
throws HeadlessException
Functions & Example of Checkbox
boolean getState( )
void setState(boolean on)
String getLabel( )
void setLabel(String str)
CheckboxGroup
Creates mutually exclusive check boxes
Also called as radio button, only one can be selected
First we need to create group and then individual checkboxes
Check box groups are objects of class / type CheckboxGroup.
Checkbox getSelectedCheckbox( )
void setSelectedCheckbox(Checkbox which)
setSelectedCheckbox( ).
getSelectedCheckbox( ).
Example of CheckboxGroup
Choice Controls
popup list is created using Choice class
Each item the popup list is string and left justifiable
void add(String name)
String getSelectedItem( )
int getSelectedIndex( )
int getItemCount( )
void select(int index)
void select(int index)
String getItem(int index)
Example of Choice Controls
Lists
Scrolling selection list is created using List class
Multiple selection of options are available
Can show any number of choices in visible window
List( ) throws HeadlessException
List(int numRows) throws HeadlessException
List(int numRows, boolean multipleSelect) throws HeadlessException
Functions in Lists
void add(String name)
void add(String name, int index)
String getSelectedItem( )
int getSelectedIndex( )
String[ ] getSelectedItems( )
int[ ] getSelectedIndexes( )
int getItemCount( )
void select(int index)
void select(int index)
String getItem(int index)
Functions in Lists
Scroll Bars
Scroll bars are used to select continuous values between specified
minimum and maximum
The current value of the scroll bar relative to its minimum and
maximum values is indicated by the slider box (or thumb) for the
scroll bar.
Scroll bars are created using Scrollbar class
Scrollbar( ) throws HeadlessException
Scrollbar(int style) throws HeadlessException
Scrollbar(int style, int initialValue, int thumbSize, int min, int max)
throws HeadlessException
Functions of Scrollbar
void setValues(int initialValue, int thumbSize, int min, int max)
int getValue( )
void setValue(int newValue)
int getMinimum( ), int getMaximum( )
void setUnitIncrement(int newIncr)
void setBlockIncrement(int newIncr)
getAdjustmentType( )
Example of Scrollbar
TextField
Single line text entry is created using TextField class
Also called edit control
TextField class is a subclass of TextComponent class
TextField( ) throws HeadlessException
TextField(int numChars) throws HeadlessException
TextField(String str) throws HeadlessException
TextField(String str, int numChars) throws HeadlessException
Functions of TextField class
String getText( )
void setText(String str)
String getSelectedText( )
void select(int startIndex, int endIndex)
boolean isEditable( )
void setEditable(boolean canEdit)
void setEchoChar(char ch)
Example of TextField
TextArea
Multiline editor is created using TextArea class
TextArea( ) throws HeadlessException
TextArea(int numLines, int numChars) throws HeadlessException
TextArea(String str) throws HeadlessException
TextArea(String str, int numLines, int numChars) throws HeadlessException
TextArea(String str, int numLines, int numChars, int sBars) throws
HeadlessException
Functions & Example of TextArea
void append(String str)
void insert(String str, int index)
void replaceRange(String str, int
startIndex, int endIndex)
TextArea class is subclass of
TextComponent class
Layout Managers
Layout manager decides where to place controls in window
Each container object has layout manager associated with it
Layout manager is instance/object of any class that implements
LayoutManager interface
void setLayout(LayoutManager layoutObj)
void setLayout(LayoutManager layoutObj)
If setLayout() function is not used then default
layout manager is used
LayoutManager classes
FlowLayout BorderLayout
CardLayoutGridLayout
GridBagLayout
Question Spot !!
Identify AWT controls and Layout managers for
User Interface of Student Registration System of
Government Polytechnic Gadchiroli
Components are placed left to right
and top to bottom like text editor
FlowLayout( )
FlowLayout
It is default layout manager
FlowLayout(int how)
FlowLayout(int how, int horz, int vert)
Example of Flowlyout
BorderLayout
Border layout devides
window into 5 components
These are north, south , east, west
and center
BorderLayout( )
void add(Component compObj, Object region)
BorderLayout(int horz,
int vert)
Example of BorderLayout
Insets
Insets is used to provide small amount of space betweeen the container
that holds your components and the window that contains it.
getInsets( ) method of container class is used for this.
Insets(int top, int left, int bottom, int right)
Insets getInsets( )
GridLayout
GridLayout uses two
dimensional grid
Number of rows and columns are
defined
GridLayout( )
GridLayout(int numRows, int numColumns, int horz, int vert)
GridLayout(int numRows,
int numColumns)
Example of GridLayout
CardLayout stores various
other layouts Each layout is like card in a deck
CardLayout( )
The cards held in object off
class/type Panel
CardLayout(int horz, int vert)
CardLayout
The cards that form the deck
are also typically objects of
class/type Panel
void add(Component
panelObj, Object name)
void first(Container deck)
void next(Container
deck)
void previous(Container deck)
void last(Container deck)
CardLayout
void show(Container deck,
String cardName)
Example of CardLayout
We can specify relative
position of components
within cell inside grid
Each component has different size
void setConstraints(Component
comp, GridBagConstraints cons)
Location,size, constraints of
components is contained in object of
GridBagConstraints class
Each row in grid have different
no. of columns
GridBagLayoutGridBagLayout( )
Example of GridBagLayout
Generally top level window
has menubar associated
with it
Menu bar displayes list of top level
menu choices
Menu is subclass of MenuItemEach Menu object contains list of
MenuItem objects
Menu bar containes one or
more Menu objects
Three classes use:
MenuBar, Menu,
MenuItem
Menu Bars,Menus &
Menu Items
Checkable menu items can
also be created using
CheckboxMenuItem class
Menu( ) throws HeadlessException
MenuItem(String itemName)
throws HeadlessException
Menu(String optionName, boolean
removable) throws HeadlessException
Menu(String optionName)
throws HeadlessException
MenuItem( ) throws
HeadlessException Menu Bars,Menus &
Menu Items
MenuItem(String itemName,
MenuShortcut keyAccel)
throws HeadlessException
void setEnabled(boolean enabledFlag)
CheckboxMenuItem( ) throws
HeadlessException
String getLabel( )
void setLabel(String newName)
boolean isEnabled( )
Menu Bars,Menus &
Menu Items
CheckboxMenuItem(String itemName)
throws HeadlessException
Menu add(Menu menu)
MenuItem add(MenuItem item)
CheckboxMenuItem(String
itemName, boolean on) throws
HeadlessException
Menu Bars,Menus &
Menu Items
void setState(boolean
checked)
boolean getState( )
Object getItem( )
Example of MenuBar,Menu,MenuItem
Menus
MenuBar
MenuItems
Dialog boxes are used to get user input
Modeless dialog box: can access
other parts windows
Model dialog box: cannot access
other part of windows
They are child windows of top
level windows
Dialog Boxes
Dialog boxes don't
have menu bars
They function as
frame windows
Dialog(Frame
parentWindow, boolean
mode)
Dialog(Frame
parentWindow, String
title, boolean mode)
Example of DialogBox
Object of FileDialog class is used to
created file dialog box
String getFile( )
It is generally provided by
operating system
FileDialog
FileDialog(Frame parent)
String getDirectory( )
FileDialog(Frame parent,
String boxName, int how)FileDialog(Frame parent,
String boxName)
Example of FileDialog
Activity Time
Assessment Test
Program Assignment
Group Discussion
Supplemental
Video
https://nptel.ac.in/courses/106/105/1
06105191/
Additional Resources
https://www.tutorialspoint.com/java
https://www.javatpoint.com/free-java-
projects
Summary of Class
Unit Recap 1
Types of
Winodws
Unit Recap 2
Creating
windowed
programs
Unit Recap 3
AWT Controls.
2
1
3
4
Unit Recap 4
Layout
Managers
References
The Complete Reference Java Seventh Edition - Herbert
Schildt,McGraw Hill Publication
Thank You
For Attending!

More Related Content

What's hot

Message Queuing (MSMQ)
Message Queuing (MSMQ)Message Queuing (MSMQ)
Message Queuing (MSMQ)Senior Dev
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread SynchronizationBenj Del Mundo
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class libraryPrem Kumar Badri
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in javaAdil Mehmoood
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in javakamal kotecha
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorSunipa Bera
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp PresentationVishwa Mohan
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in javaGoogle
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART IOXUS 20
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletraksharao
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managersswapnac12
 

What's hot (20)

Message Queuing (MSMQ)
Message Queuing (MSMQ)Message Queuing (MSMQ)
Message Queuing (MSMQ)
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
C# in depth
C# in depthC# in depth
C# in depth
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 

Similar to Unit-1 awt advanced java programming

Similar to Unit-1 awt advanced java programming (20)

Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Unit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxUnit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptx
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Java swing
Java swingJava swing
Java swing
 
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
 
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
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Java swing
Java swingJava swing
Java swing
 
B.Sc. III(VI Sem) Advance Java Unit3: AWT & Event Handling
B.Sc. III(VI Sem) Advance Java Unit3: AWT & Event HandlingB.Sc. III(VI Sem) Advance Java Unit3: AWT & Event Handling
B.Sc. III(VI Sem) Advance Java Unit3: AWT & Event Handling
 
DSJ_Unit III.pdf
DSJ_Unit III.pdfDSJ_Unit III.pdf
DSJ_Unit III.pdf
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Awt
AwtAwt
Awt
 
AWT New-3.pptx
AWT New-3.pptxAWT New-3.pptx
AWT New-3.pptx
 
Jp notes
Jp notesJp notes
Jp notes
 
Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 

More from Amol Gaikwad

IT Resources for Students.pdf
IT Resources for Students.pdfIT Resources for Students.pdf
IT Resources for Students.pdfAmol Gaikwad
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfAmol Gaikwad
 
How To Prepare Resume.pdf
How To Prepare Resume.pdfHow To Prepare Resume.pdf
How To Prepare Resume.pdfAmol Gaikwad
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformationsAmol Gaikwad
 
Unit 1 संगणक प्रणाली ( computer system ) ची ओळख
Unit 1 संगणक प्रणाली ( computer system ) ची ओळखUnit 1 संगणक प्रणाली ( computer system ) ची ओळख
Unit 1 संगणक प्रणाली ( computer system ) ची ओळखAmol Gaikwad
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in javaAmol Gaikwad
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handlingAmol Gaikwad
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architectureAmol Gaikwad
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphicsAmol Gaikwad
 

More from Amol Gaikwad (10)

IT Resources for Students.pdf
IT Resources for Students.pdfIT Resources for Students.pdf
IT Resources for Students.pdf
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
How To Prepare Resume.pdf
How To Prepare Resume.pdfHow To Prepare Resume.pdf
How To Prepare Resume.pdf
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformations
 
Unit 1 संगणक प्रणाली ( computer system ) ची ओळख
Unit 1 संगणक प्रणाली ( computer system ) ची ओळखUnit 1 संगणक प्रणाली ( computer system ) ची ओळख
Unit 1 संगणक प्रणाली ( computer system ) ची ओळख
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handling
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
Unit-2 swing and mvc architecture
Unit-2 swing and mvc architectureUnit-2 swing and mvc architecture
Unit-2 swing and mvc architecture
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphics
 

Recently uploaded

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilVinayVitekari
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptxrouholahahmadi9876
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Recently uploaded (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Unit-1 awt advanced java programming

  • 1. Advanced Java Programming by Amol S. Gaikwad Lecturer, Government Polytechnic Gadchiroli
  • 3. Welcome! Are you excited for a fun learning session? Unit Outcomes Develop Graphical User (GUI) programs using AWT Components for given component Create frame window with specified AWT components Develop programs using menu and Dialog Boxes for the given Arrange the GUI components using specified AWT components
  • 4. What is AWT ? Abstract Window Toolkit (AWT) is one of java's largest packages AWT containes many classess and methods We can create user interface with AWT. AWT classes are present in java.awt package AWT is use to create and manage windows
  • 5. Windows Fundamentals Component class Container class Window class Panel class Frame class Fig 1.1 The class hierarchy of Panel and Frame
  • 6. Component object remembers foreground,background, text font Component Class Top of AWT heirarchy All UI elements are subclass of this class Has 100 public methods Manages events such as mouse and keyboard i/p
  • 7. Container Class This class is sublcass of Component class Has methods Component objects to be nested within it. This class is responsible for laying out components Other conatiner objects can be stored inside of a container It uses various layout managers
  • 8. Panel Class This class is sublcass of Container class No new methods, simply implements Container Applet output is drawn on surface of Panel object Panel is superclass for Applet Other components can be added to a Panel object by its add( ) method Panel window doesn't contain title bar, menu bar, or border
  • 9. Window Class This class creates a top level window A top level window is not contained in any other object It directly sits on desktop Generally we don't create Window object directly Instead we use sublcass of Window called Frame
  • 10. Canvas Class Canvas is a not a part of heirarchy Canvas is a blank window on which you can draw It is other type of window
  • 11. Creating Frame windows Setting window's dimensions Frame( ) Frame( String title) Frame class constructors void setSize(int newWidth, int newHeight) void setSize(Dimension newSize) Dimension getSize( )
  • 12. Creating Frame windows Setting a window's title void setVisible(boolean visibleFlag) Hiding and showing a window void setTitle(String newTitle) setVisible(false) windowClosing( ) Closing a Frame window
  • 13. Output of Frame window Applet window Frame window
  • 15. AWT controls and layout managers Controls are components that allows to interact with the application Layout managers automatically positions components within a container Menu bar creates a drop down menus of options from which we can select options
  • 16. AWT controls List AWT supports following types of controls Labels Push buttons Check boxes Choice list Lists Scroll bars Text Editing
  • 18. Labels A label is an object of class/type Label It contains a string displayed on screen It is passive control and doesn't support any interaction Constructors of Label class Label( ) throws HeadlessException Label(String str) throws HeadlessException Label(String str, int how) throws HeadlessException
  • 19. Functions & Example of Labels void setText(String str) String getText( ) void setAlignment(int how) void setAlignment(int how) int getAlignment( )
  • 20. Buttons A push button is an object of class/type Button A push button contains a label It can be pressed to generate event Button( ) throws HeadlessException Button(String str) throws HeadlessException void setLabel(String str) String getLabel( )
  • 22. Checkbox A checkbox is an object of class/type Checkbox It has a small box which can be checked Checkbox has label It's state can be changed by clicking it Check boxes can be used individually or part of a group
  • 23. Constructors of Checkbox Checkbox( ) throws HeadlessException Checkbox(String str) throws HeadlessException Checkbox(String str, boolean on) throws HeadlessException Checkbox(String str, boolean on, CheckboxGroup cbGroup) throws HeadlessException Checkbox(String str, CheckboxGroup cbGroup, boolean on) throws HeadlessException
  • 24. Functions & Example of Checkbox boolean getState( ) void setState(boolean on) String getLabel( ) void setLabel(String str)
  • 25. CheckboxGroup Creates mutually exclusive check boxes Also called as radio button, only one can be selected First we need to create group and then individual checkboxes Check box groups are objects of class / type CheckboxGroup. Checkbox getSelectedCheckbox( ) void setSelectedCheckbox(Checkbox which) setSelectedCheckbox( ). getSelectedCheckbox( ).
  • 27. Choice Controls popup list is created using Choice class Each item the popup list is string and left justifiable void add(String name) String getSelectedItem( ) int getSelectedIndex( ) int getItemCount( ) void select(int index) void select(int index) String getItem(int index)
  • 28. Example of Choice Controls
  • 29. Lists Scrolling selection list is created using List class Multiple selection of options are available Can show any number of choices in visible window List( ) throws HeadlessException List(int numRows) throws HeadlessException List(int numRows, boolean multipleSelect) throws HeadlessException
  • 30. Functions in Lists void add(String name) void add(String name, int index) String getSelectedItem( ) int getSelectedIndex( ) String[ ] getSelectedItems( ) int[ ] getSelectedIndexes( ) int getItemCount( ) void select(int index) void select(int index) String getItem(int index)
  • 32. Scroll Bars Scroll bars are used to select continuous values between specified minimum and maximum The current value of the scroll bar relative to its minimum and maximum values is indicated by the slider box (or thumb) for the scroll bar. Scroll bars are created using Scrollbar class Scrollbar( ) throws HeadlessException Scrollbar(int style) throws HeadlessException Scrollbar(int style, int initialValue, int thumbSize, int min, int max) throws HeadlessException
  • 33. Functions of Scrollbar void setValues(int initialValue, int thumbSize, int min, int max) int getValue( ) void setValue(int newValue) int getMinimum( ), int getMaximum( ) void setUnitIncrement(int newIncr) void setBlockIncrement(int newIncr) getAdjustmentType( )
  • 35. TextField Single line text entry is created using TextField class Also called edit control TextField class is a subclass of TextComponent class TextField( ) throws HeadlessException TextField(int numChars) throws HeadlessException TextField(String str) throws HeadlessException TextField(String str, int numChars) throws HeadlessException
  • 36. Functions of TextField class String getText( ) void setText(String str) String getSelectedText( ) void select(int startIndex, int endIndex) boolean isEditable( ) void setEditable(boolean canEdit) void setEchoChar(char ch)
  • 38. TextArea Multiline editor is created using TextArea class TextArea( ) throws HeadlessException TextArea(int numLines, int numChars) throws HeadlessException TextArea(String str) throws HeadlessException TextArea(String str, int numLines, int numChars) throws HeadlessException TextArea(String str, int numLines, int numChars, int sBars) throws HeadlessException
  • 39. Functions & Example of TextArea void append(String str) void insert(String str, int index) void replaceRange(String str, int startIndex, int endIndex) TextArea class is subclass of TextComponent class
  • 40. Layout Managers Layout manager decides where to place controls in window Each container object has layout manager associated with it Layout manager is instance/object of any class that implements LayoutManager interface void setLayout(LayoutManager layoutObj) void setLayout(LayoutManager layoutObj) If setLayout() function is not used then default layout manager is used
  • 42. Question Spot !! Identify AWT controls and Layout managers for User Interface of Student Registration System of Government Polytechnic Gadchiroli
  • 43. Components are placed left to right and top to bottom like text editor FlowLayout( ) FlowLayout It is default layout manager FlowLayout(int how) FlowLayout(int how, int horz, int vert)
  • 45. BorderLayout Border layout devides window into 5 components These are north, south , east, west and center BorderLayout( ) void add(Component compObj, Object region) BorderLayout(int horz, int vert)
  • 47. Insets Insets is used to provide small amount of space betweeen the container that holds your components and the window that contains it. getInsets( ) method of container class is used for this. Insets(int top, int left, int bottom, int right) Insets getInsets( )
  • 48. GridLayout GridLayout uses two dimensional grid Number of rows and columns are defined GridLayout( ) GridLayout(int numRows, int numColumns, int horz, int vert) GridLayout(int numRows, int numColumns)
  • 50. CardLayout stores various other layouts Each layout is like card in a deck CardLayout( ) The cards held in object off class/type Panel CardLayout(int horz, int vert) CardLayout The cards that form the deck are also typically objects of class/type Panel
  • 51. void add(Component panelObj, Object name) void first(Container deck) void next(Container deck) void previous(Container deck) void last(Container deck) CardLayout void show(Container deck, String cardName)
  • 53. We can specify relative position of components within cell inside grid Each component has different size void setConstraints(Component comp, GridBagConstraints cons) Location,size, constraints of components is contained in object of GridBagConstraints class Each row in grid have different no. of columns GridBagLayoutGridBagLayout( )
  • 55. Generally top level window has menubar associated with it Menu bar displayes list of top level menu choices Menu is subclass of MenuItemEach Menu object contains list of MenuItem objects Menu bar containes one or more Menu objects Three classes use: MenuBar, Menu, MenuItem Menu Bars,Menus & Menu Items
  • 56. Checkable menu items can also be created using CheckboxMenuItem class Menu( ) throws HeadlessException MenuItem(String itemName) throws HeadlessException Menu(String optionName, boolean removable) throws HeadlessException Menu(String optionName) throws HeadlessException MenuItem( ) throws HeadlessException Menu Bars,Menus & Menu Items
  • 57. MenuItem(String itemName, MenuShortcut keyAccel) throws HeadlessException void setEnabled(boolean enabledFlag) CheckboxMenuItem( ) throws HeadlessException String getLabel( ) void setLabel(String newName) boolean isEnabled( ) Menu Bars,Menus & Menu Items
  • 58. CheckboxMenuItem(String itemName) throws HeadlessException Menu add(Menu menu) MenuItem add(MenuItem item) CheckboxMenuItem(String itemName, boolean on) throws HeadlessException Menu Bars,Menus & Menu Items void setState(boolean checked) boolean getState( ) Object getItem( )
  • 60. Dialog boxes are used to get user input Modeless dialog box: can access other parts windows Model dialog box: cannot access other part of windows They are child windows of top level windows Dialog Boxes Dialog boxes don't have menu bars They function as frame windows Dialog(Frame parentWindow, boolean mode) Dialog(Frame parentWindow, String title, boolean mode)
  • 62. Object of FileDialog class is used to created file dialog box String getFile( ) It is generally provided by operating system FileDialog FileDialog(Frame parent) String getDirectory( ) FileDialog(Frame parent, String boxName, int how)FileDialog(Frame parent, String boxName)
  • 64. Activity Time Assessment Test Program Assignment Group Discussion
  • 67. Summary of Class Unit Recap 1 Types of Winodws Unit Recap 2 Creating windowed programs Unit Recap 3 AWT Controls. 2 1 3 4 Unit Recap 4 Layout Managers
  • 68. References The Complete Reference Java Seventh Edition - Herbert Schildt,McGraw Hill Publication