INTEGRATIVE PROGRAMMING & TECHNOLOGIES
CHAPTER 1
Graphical User Interfaces
DESCRIBES ABSTRACT WINDOW TOOLKIT (AWT) FUNDAMENTALS�
CLO
COURSE CONTENT OUTLINE
1.2 Build Frame Windows and Menu Bars in Java programs. [CLO1, CLO2]
1.1 Describes Abstract Window Toolkit (AWT) fundamentals. [CLO1]
Build Frame Windows and Menu Bars in Java programs.
THREE PART OF GUI
A GUI program consists of three types of software:
WHAT IS AWT?
WHAT IS AWT?
AWT FUNDAMENTALS
AWT FUNDAMENTALS
AWT FUNDAMENTALS
AWT PACKAGE
AWT PACKAGE
java.awt Basic component functionality
java.awt.accessibility Assistive technologies
java.awt.color Colors and color spaces
java.awt.datatransfer Clipboard and data transfer support
java.awt.dnd Drag and drop
java.awt.event Event classes and listeners
java.awt.font 2D API font package
java.awt.geom 2D API geometry package
java.awt.im Input methods
java.awt.image Fundamental image manipulation classes
java.awt.peer Peer interfaces for component peers
java.awt.print 2D API support for printing
java.awt.swing Swing components
FOUR MAIN COMPONENTS IN AWT:
a) Container
• Container inherits AWT class and it consists of other components, including the other containers. A common container is called Panels.
b) Canvases
• Canvas is an easy surface for drawing. It is good to colour an image or to execute other graphical operations.
c) Interface Component
• User Interface includes button, list, simple pop-up, menu, check box, TextField and other usual interface elements.
d) Window Construction
• The window components include window, frame, bar menu and dialog box.
Windows Fundamentals
Windows Fundamentals
WINDOWS FUNDAMENTALS
AWT
AWT
COMPONENTS
COMPONENTS
The Component class defines data and methods which are relevant to all Components
CONTAINER
CONTAINER
The Container class defined all the data and methods necessary for managing groups of Components
Top-Level Containers: Frame, Dialog and Applet
Container
TO WRITE A GUI PROGRAM, WE TYPICALLY START WITH A SUBCLASS EXTENDING FROM JAVA.AWT.FRAME TO INHERIT THE MAIN WINDOW AS FOLLOWS:�
CONTAINER
CONTAINER
Panel
Panel
Panel
Panel
- Setting the colour
- Setting the size
- Getting an events.
Canvas
Canvas
Window
CREATING USER INTERFACE (WITHOUT EVENT)
Graphical User Interface (GUI) is easy which tackles users to use the system.
• Building a GUI requires creativity and knowledge on how GUI components function.
• add() method is used to add components into container.
• remove() method used to discard component from container.
Frame
Frame
The Use of Frame
FRAME WINDOW
public static void main(String args[]
void setTitle(String newTitle)
Setting a Window’s Title
void setSize(int newWidth, int newHeight)
void setSize(Dimension newSize)
Setting the Window’s Dimensions
Closing a Frame Window
Creating Frame
Menu Bars & Menu
Menu Bars & Menu
Menu Bars & Menu
MENU BARS & MENU
Dialog
Dialog Box
Dialog
Dialog Box
Applet
Applet
GUI COMPONENTS
a) Label
b) List
c) TextField
d) Button
e) TextArea
f) Choice
g) CheckBox
i. Label()
ii. Label(String s)
iii. Label(String s, int alignment)
Label
Label
i. Button()
ii. Button(String s)
Button
Button
i. Checkbox()
ii. Checkbox(String str)
iii. Checkbox(String str, Boolean on)
CheckBox
CheckBox
i. TextField(int width)
ii. TextField(String s)
iii. TextField(String s, int width)
TextField
GUI COMPONENTS
TextField
i. TextArea(int rows, int columns)
ii. TextArea(String s, int rows, int columns)
TextArea
TextArea
choice()
Choice
Choice
i. List(int rows, Boolean multipleSelection)
- creates a new scrolling list with the specifics number of visible
rows and enable to use parameter “multipleSelection” .
ii. List()
List
List
REVISION
A. True
B. False
Q1
REVISION
A. A container is another name for an array or vector.
B. A container is any class that is made up of other classes.
C. A container is a primitive variable that contains the actual data.
D. A container is an object like a Frame that has other GUI components placed inside of it.
Q2
REVISION
import java.awt.*; public class microGUI {
public static void main ( String[] args ) {
Frame frm = new ___________();
frm.___________( 150, 100 );
frm.___________( true );
} } �
Q3
REVISION
A. frm.setSize( 300, 200 );
B. frm.setSize( 200, 300 );
C. frm.paint( 300, 200 );
D. frm.setVisible( 300, 200 )
Q4
REVISION
import java.awt.*;
class helloFrame ___________ Frame {
public void ___________( Graphics g )
{ g.___________("Hello", 10, 50 );
} }
public class Tester {
public static void main ( String[] args ) {
helloFrame frm = new helloFrame();
frm.setSize( 150, 100 ); frm.setVisible( true );
} }
Q5
REVISION
_______________________________________
Q6
REVISION
_______________________________________
Q7