SlideShare a Scribd company logo
1 of 15
Agenda
 Graphical User Interface and Basic Terminologies
 AWT Controls
 SWING Controls
Graphical User Interface and Basic Terminologies
 Graphical User Interface (GUI) offers user interaction via some graphical components.
 For example our underlying Operating System also offers GUI via
window,frame,Panel, Button, Textfield, TextArea, Listbox, Combobox, Label,
Checkbox etc.
 These all are known as components. Using these components we can create an
interactive user interface for an application.
 GUI provides result to end user in response to raised events.
 GUI is entirely based events. For example clicking over a button, closing a window,
opening a window, typing something in a textarea etc.
 These activities are known as events.GUI makes it easier for the end user to use an
application. It also makes them interesting.
Graphical User Interface and Basic Terminologies
Term Description
Component Component is an object having a graphical representation that can be displayed on the screen and that can interact
with the user. For examples buttons, checkboxes, list and scrollbars of a graphical user interface.
Container Container object is a component that can contain other components.Components added to a container are tracked in a
list. The order of the list will define the components' front-to-back stacking order within the container. If no index is
specified when adding a component to a container, it will be added to the end of the list.
Panel Panel provides space in which an application can attach any other components, including other panels.
Window Window is a rectangular area which is displayed on the screen. In different window we can execute different program
and display different data. Window provide us with multitasking environment. A window must have either a frame,
dialog, or another window defined as its owner when it's constructed.
Frame A Frame is a top-level window with a title and a border. The size of the frame includes any area designated for the
border. Frame encapsulates window. It and has a title bar, menu bar, borders, and resizing corners.
Canvas Canvas component represents a blank rectangular area of the screen onto which the application can draw. Application
can also trap input events from the use from that blank area of Canvas component.
Graphical User Interface and Basic Terminologies
 Examples of GUI based Applications
 Automated Teller Machine (ATM)
 Airline Ticketing System
 Information Kiosks at railway stations
 Mobile Applications
 Navigation Systems
 Advantages of GUI over CUI
 GUI provides graphical icons to interact while the CUI (Character User Interface) offers the simple text-based interfaces.
 GUI makes the application more entertaining and interesting on the other hand CUI does not.
 GUI offers click and execute environment while in CUI every time we have to enter the command for a task.
 New user can easily interact with graphical user interface by the visual indicators but it is difficult in Character user
interface.
 GUI offers a lot of controls of file system and the operating system while in CUI you have to use commands which is
difficult to remember.
 Windows concept in GUI allow the user to view, manipulate and control the multiple applications at once while in CUI
user can control one task at a time.
 GUI provides multitasking environment so as the CUI also does but CUI does not provide same ease as the GUI do.
 Using GUI it is easier to control and navigate the operating system which becomes very slow in command user interface.
GUI can be easily customized.
AWT Controls
 Every user interface considers the
following three main aspects:
 UI elements : These are the core visual
elements the user eventually sees and
interacts with. GWT provides a huge list
of widely used and common elements
varying from basic to complex
 Layouts: They define how UI elements
should be organized on the screen and
provide a final look and feel to the GUI
(Graphical User Interface).
 Behavior: These are events which occur
when the user interacts with UI
elements.
AWT Controls
Control & Description
Component - A Component is an abstract super class for GUI controls and it represents an object with graphical representation.
Label - A Label object is a component for placing text in a container.
Button - This class creates a labeled button.
Check Box - A check box is a graphical component that can be in either an on(true) or off (false) state.
Check Box Group - The CheckboxGroup class is used to group the set of checkbox.
List - The List component presents the user with a scrolling list of text items.
Text Field - A TextField object is a text component that allows for the editing of a single line of text.
Text Area - A TextArea object is a text component that allows for the editing of a multiple lines of text.
Choice - A Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu.
Canvas - A Canvas control represents a rectangular area where application can draw something or can receive inputs created by user.
Image - An Image control is superclass for all image classes representing graphical images.
Scroll Bar - A Scrollbar control represents a scroll bar component in order to enable user to select from range of values.
Dialog - A Dialog control represents a top-level window with a title and a border used to take some form of input from the user.
File Dialog - A FileDialog control represents a dialog window from which the user can select a file.
AWT Controls
 Examples of GUI based Applications
 Automated Teller Machine (ATM)
 Airline Ticketing System
 Information Kiosks at railway stations
 Mobile Applications
 Navigation Systems
 Advantages of GUI over CUI
 GUI provides graphical icons to interact while the CUI (Character User Interface) offers the simple text-based interfaces.
 GUI makes the application more entertaining and interesting on the other hand CUI does not.
 GUI offers click and execute environment while in CUI every time we have to enter the command for a task.
 New user can easily interact with graphical user interface by the visual indicators but it is difficult in Character user
interface.
 GUI offers a lot of controls of file system and the operating system while in CUI you have to use commands which is
difficult to remember.
 Windows concept in GUI allow the user to view, manipulate and control the multiple applications at once while in CUI
user can control one task at a time.
 GUI provides multitasking environment so as the CUI also does but CUI does not provide same ease as the GUI do.
 Using GUI it is easier to control and navigate the operating system which becomes very slow in command user interface.
GUI can be easily customized.
 For more information : https://docs.oracle.com/javase/8/docs/api/java/awt/package-frame.html
AWT Controls
How to Add Frame
private Frame mainFrame;
mainFrame = new Frame("Java AWT Examples");
mainFrame.setSize(400,400);
mainFrame.setLayout(new GridLayout(3, 1));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
How to Add Label
private Label headerLabel;
headerLabel = new Label();
headerLabel.setAlignment(Label.CENTER);
statusLabel = new Label();
statusLabel.setAlignment(Label.CENTER);
statusLabel.setSize(350,100);
How to Add Panel
private Panel controlPanel;
controlPanel = new Panel();
controlPanel.setLayout(new FlowLayout());
How to Add Components to Frame
mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.setVisible(true);
AWT Controls
Full Example
import java.awt.*;
import java.awt.event.*;
public class AwtControlDemo {
private Frame mainFrame;
private Label headerLabel;
private Label statusLabel;
private Panel controlPanel;
public AwtControlDemo(){
prepareGUI();
}
public static void main(String[] args){
AwtControlDemo awtControlDemo = new AwtControlDemo();
awtControlDemo.showLabelDemo();
}
private void prepareGUI(){
mainFrame = new Frame("Java AWT Examples");
mainFrame.setSize(400,400);
mainFrame.setLayout(new GridLayout(3, 1));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
headerLabel = new Label();
headerLabel.setAlignment(Label.CENTER);
statusLabel = new Label();
statusLabel.setAlignment(Label.CENTER);
statusLabel.setSize(350,100);
controlPanel = new Panel();
controlPanel.setLayout(new FlowLayout());
mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.add(statusLabel);
mainFrame.setVisible(true);
}
private void showLabelDemo(){
headerLabel.setText("Control in action: Label");
Label label = new Label();
label.setText("Welcome to TutorialsPoint AWT Tutorial.");
label.setAlignment(Label.CENTER);
label.setBackground(Color.GRAY);
label.setForeground(Color.WHITE);
controlPanel.add(label);
mainFrame.setVisible(true);
}
}
SWING Controls
 Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front
End/GUI Applications.
 It is build on top of AWT API and acts as a replacement of AWT API, since it has almost every control
corresponding to AWT controls.
 Swing component follows a Model-View-Controller architecture to fulfill the following criterias.
 A single API is to be sufficient to support multiple look and feel.
 API is to be model driven so that the highest level API is not required to have data.
 API is to use the Java Bean model so that Builder Tools and IDE can provide better services to the developers
for use.
 Swing API architecture follows loosely based MVC architecture in the following manner.
 Model represents component's data.
 View represents visual representation of the component's data.
 Controller takes the input from the user on the view and reflects the changes in Component's data.
 Swing component has Model as a seperate element, while the View and Controller part are clubbed in the
User Interface elements. Because of which, Swing has a pluggable look-and-feel architecture.
SWING Controls
 Swing Features
 Light Weight − Swing components are independent of native Operating System's API as
Swing API controls are rendered mostly using pure JAVA code instead of underlying
operating system calls.
 Rich Controls − Swing provides a rich set of advanced controls like Tree, TabbedPane,
slider, colorpicker, and table controls.
 Highly Customizable − Swing controls can be customized in a very easy way as visual
apperance is independent of internal representation.
 Pluggable look-and-feel − SWING based GUI Application look and feel can be changed at
run-time, based on available values.
 For more information :
https://docs.oracle.com/javase/8/docs/api/index.html?javax/swing/package-
summary.html
SWING Controls
 Every user interface considers the
following three main aspects −
 UI Elements − These are the core
visual elements the user eventually
sees and interacts with. GWT
provides a huge list of widely used
and common elements varying from
basic to complex
 Layouts − They define how UI
elements should be organized on the
screen and provide a final look and
feel to the GUI (Graphical User
Interface).
 Behavior − These are the events
which occur when the user interacts
with UI elements.
SWING Controls -
Class & Description
Component - A Component is the abstract base class for the non menu user-interface controls of SWING. Component represents an object with graphical representation
Container - A Container is a component that can contain other SWING components
Jcomponent - A JComponent is a base class for all SWING UI components. In order to use a SWING component that inherits from JComponent, the component must be
in a containment hierarchy whose root is a top-level SWING container
Jlabel – A JLabel object is a component for placing text in a container.
Jbutton - This class creates a labeled button.
JColorChooser - A JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color.
JCheck Box - A JCheckBox is a graphical component that can be in either an on(true) or off (false) state.
JRadioButton - The JRadioButton class is a graphical component that can be in either an on (true) or off (false) state. in a group.
Jlist - A JList component presents the user with a scrolling list of text items.
JComboBox - A JComboBox component presents the user with a to show up menu of choices.
JTextField - A JTextField object is a text component that allows for the editing of a single line of text.
JPasswordField - A JPasswordField object is a text component specialized for password entry.
JTextArea - A JTextArea object is a text component that allows editing of a multiple lines of text.
ImageIcon - A ImageIcon control is an implementation of the Icon interface that paints Icons from Images
Jscrollbar - A Scrollbar control represents a scroll bar component in order to enable the user to select from range of values.
JOptionPane - JOptionPane provides set of standard dialog boxes that prompt users for a value or informs them of something.
JFileChooser - A JFileChooser control represents a dialog window from which the user can select a file.
JProgressBar - As the task progresses towards completion, the progress bar displays the task's percentage of completion.
Jslider - A JSlider lets the user graphically select a value by sliding a knob within a bounded interval.
SWING Controls
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingControlDemo {
private JFrame mainFrame;
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;
public SwingControlDemo(){
prepareGUI();
}
public static void main(String[] args){
SwingControlDemo swingControlDemo = new SwingControlDemo();
swingControlDemo.showButtonDemo();
}
private void prepareGUI(){
mainFrame = new JFrame("Java Swing Examples");
mainFrame.setSize(400,400);
mainFrame.setLayout(new GridLayout(3, 1));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
headerLabel = new JLabel("", JLabel.CENTER);
statusLabel = new JLabel("",JLabel.CENTER);
statusLabel.setSize(350,100);
controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
mainFrame.add(headerLabel);
private static ImageIcon createImageIcon(String path, String description) {
java.net.URL imgURL = SwingControlDemo.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
private void showButtonDemo(){
headerLabel.setText("Control in action: Button");
//resources folder should be inside SWING folder.
ImageIcon icon = createImageIcon("/resources/java_icon.png","Java");
JButton okButton = new JButton("OK");
JButton javaButton = new JButton("Submit", icon);
JButton cancelButton = new JButton("Cancel", icon);
cancelButton.setHorizontalTextPosition(SwingConstants.LEFT);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusLabel.setText("Ok Button clicked.");
}
});
javaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusLabel.setText("Submit Button clicked.");
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusLabel.setText("Cancel Button clicked.");
}
});

More Related Content

Similar to ITE 1122_ AWT and SWING.pptx

Similar to ITE 1122_ AWT and SWING.pptx (20)

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
 
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
 
HCI 3e - Ch 8: Implementation support
HCI 3e - Ch 8:  Implementation supportHCI 3e - Ch 8:  Implementation support
HCI 3e - Ch 8: Implementation support
 
Advanced swing
Advanced swingAdvanced swing
Advanced swing
 
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
 
Java lab lecture 2
Java  lab  lecture 2Java  lab  lecture 2
Java lab lecture 2
 
The Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a WidgetThe Use of Java Swing’s Components to Develop a Widget
The Use of Java Swing’s Components to Develop a Widget
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Java session13
Java session13Java session13
Java session13
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
 
DHTMLX
DHTMLXDHTMLX
DHTMLX
 
Gui
GuiGui
Gui
 
Graphical User Interface (GUI)
Graphical User Interface (GUI)Graphical User Interface (GUI)
Graphical User Interface (GUI)
 
Publication Non Visual Components
Publication Non Visual ComponentsPublication Non Visual Components
Publication Non Visual Components
 
Neha
NehaNeha
Neha
 
DHTMLX_NEW
DHTMLX_NEWDHTMLX_NEW
DHTMLX_NEW
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 

Recently uploaded

Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...Suhani Kapoor
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknowmakika9823
 
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一ga6c6bdl
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfchapmanellie27
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Pooja Nehwal
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一ss ss
 
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一ss ss
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一ss ss
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...nagunakhan
 
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRReal Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRdollysharma2066
 
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一C SSS
 
(办理学位证)多伦多大学毕业证成绩单原版一比一
(办理学位证)多伦多大学毕业证成绩单原版一比一(办理学位证)多伦多大学毕业证成绩单原版一比一
(办理学位证)多伦多大学毕业证成绩单原版一比一C SSS
 
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》o8wvnojp
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile servicerehmti665
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gayasrsj9000
 

Recently uploaded (20)

Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
 
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
如何办理萨省大学毕业证(UofS毕业证)成绩单留信学历认证原版一比一
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
CIVIL ENGINEERING
CIVIL ENGINEERINGCIVIL ENGINEERING
CIVIL ENGINEERING
 
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
 
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
 
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRReal Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
 
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
(办理学位证)韩国汉阳大学毕业证成绩单原版一比一
 
(办理学位证)多伦多大学毕业证成绩单原版一比一
(办理学位证)多伦多大学毕业证成绩单原版一比一(办理学位证)多伦多大学毕业证成绩单原版一比一
(办理学位证)多伦多大学毕业证成绩单原版一比一
 
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile service
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
 

ITE 1122_ AWT and SWING.pptx

  • 1.
  • 2. Agenda  Graphical User Interface and Basic Terminologies  AWT Controls  SWING Controls
  • 3. Graphical User Interface and Basic Terminologies  Graphical User Interface (GUI) offers user interaction via some graphical components.  For example our underlying Operating System also offers GUI via window,frame,Panel, Button, Textfield, TextArea, Listbox, Combobox, Label, Checkbox etc.  These all are known as components. Using these components we can create an interactive user interface for an application.  GUI provides result to end user in response to raised events.  GUI is entirely based events. For example clicking over a button, closing a window, opening a window, typing something in a textarea etc.  These activities are known as events.GUI makes it easier for the end user to use an application. It also makes them interesting.
  • 4. Graphical User Interface and Basic Terminologies Term Description Component Component is an object having a graphical representation that can be displayed on the screen and that can interact with the user. For examples buttons, checkboxes, list and scrollbars of a graphical user interface. Container Container object is a component that can contain other components.Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container, it will be added to the end of the list. Panel Panel provides space in which an application can attach any other components, including other panels. Window Window is a rectangular area which is displayed on the screen. In different window we can execute different program and display different data. Window provide us with multitasking environment. A window must have either a frame, dialog, or another window defined as its owner when it's constructed. Frame A Frame is a top-level window with a title and a border. The size of the frame includes any area designated for the border. Frame encapsulates window. It and has a title bar, menu bar, borders, and resizing corners. Canvas Canvas component represents a blank rectangular area of the screen onto which the application can draw. Application can also trap input events from the use from that blank area of Canvas component.
  • 5. Graphical User Interface and Basic Terminologies  Examples of GUI based Applications  Automated Teller Machine (ATM)  Airline Ticketing System  Information Kiosks at railway stations  Mobile Applications  Navigation Systems  Advantages of GUI over CUI  GUI provides graphical icons to interact while the CUI (Character User Interface) offers the simple text-based interfaces.  GUI makes the application more entertaining and interesting on the other hand CUI does not.  GUI offers click and execute environment while in CUI every time we have to enter the command for a task.  New user can easily interact with graphical user interface by the visual indicators but it is difficult in Character user interface.  GUI offers a lot of controls of file system and the operating system while in CUI you have to use commands which is difficult to remember.  Windows concept in GUI allow the user to view, manipulate and control the multiple applications at once while in CUI user can control one task at a time.  GUI provides multitasking environment so as the CUI also does but CUI does not provide same ease as the GUI do.  Using GUI it is easier to control and navigate the operating system which becomes very slow in command user interface. GUI can be easily customized.
  • 6. AWT Controls  Every user interface considers the following three main aspects:  UI elements : These are the core visual elements the user eventually sees and interacts with. GWT provides a huge list of widely used and common elements varying from basic to complex  Layouts: They define how UI elements should be organized on the screen and provide a final look and feel to the GUI (Graphical User Interface).  Behavior: These are events which occur when the user interacts with UI elements.
  • 7. AWT Controls Control & Description Component - A Component is an abstract super class for GUI controls and it represents an object with graphical representation. Label - A Label object is a component for placing text in a container. Button - This class creates a labeled button. Check Box - A check box is a graphical component that can be in either an on(true) or off (false) state. Check Box Group - The CheckboxGroup class is used to group the set of checkbox. List - The List component presents the user with a scrolling list of text items. Text Field - A TextField object is a text component that allows for the editing of a single line of text. Text Area - A TextArea object is a text component that allows for the editing of a multiple lines of text. Choice - A Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu. Canvas - A Canvas control represents a rectangular area where application can draw something or can receive inputs created by user. Image - An Image control is superclass for all image classes representing graphical images. Scroll Bar - A Scrollbar control represents a scroll bar component in order to enable user to select from range of values. Dialog - A Dialog control represents a top-level window with a title and a border used to take some form of input from the user. File Dialog - A FileDialog control represents a dialog window from which the user can select a file.
  • 8. AWT Controls  Examples of GUI based Applications  Automated Teller Machine (ATM)  Airline Ticketing System  Information Kiosks at railway stations  Mobile Applications  Navigation Systems  Advantages of GUI over CUI  GUI provides graphical icons to interact while the CUI (Character User Interface) offers the simple text-based interfaces.  GUI makes the application more entertaining and interesting on the other hand CUI does not.  GUI offers click and execute environment while in CUI every time we have to enter the command for a task.  New user can easily interact with graphical user interface by the visual indicators but it is difficult in Character user interface.  GUI offers a lot of controls of file system and the operating system while in CUI you have to use commands which is difficult to remember.  Windows concept in GUI allow the user to view, manipulate and control the multiple applications at once while in CUI user can control one task at a time.  GUI provides multitasking environment so as the CUI also does but CUI does not provide same ease as the GUI do.  Using GUI it is easier to control and navigate the operating system which becomes very slow in command user interface. GUI can be easily customized.  For more information : https://docs.oracle.com/javase/8/docs/api/java/awt/package-frame.html
  • 9. AWT Controls How to Add Frame private Frame mainFrame; mainFrame = new Frame("Java AWT Examples"); mainFrame.setSize(400,400); mainFrame.setLayout(new GridLayout(3, 1)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); } }); How to Add Label private Label headerLabel; headerLabel = new Label(); headerLabel.setAlignment(Label.CENTER); statusLabel = new Label(); statusLabel.setAlignment(Label.CENTER); statusLabel.setSize(350,100); How to Add Panel private Panel controlPanel; controlPanel = new Panel(); controlPanel.setLayout(new FlowLayout()); How to Add Components to Frame mainFrame.add(headerLabel); mainFrame.add(controlPanel); mainFrame.setVisible(true);
  • 10. AWT Controls Full Example import java.awt.*; import java.awt.event.*; public class AwtControlDemo { private Frame mainFrame; private Label headerLabel; private Label statusLabel; private Panel controlPanel; public AwtControlDemo(){ prepareGUI(); } public static void main(String[] args){ AwtControlDemo awtControlDemo = new AwtControlDemo(); awtControlDemo.showLabelDemo(); } private void prepareGUI(){ mainFrame = new Frame("Java AWT Examples"); mainFrame.setSize(400,400); mainFrame.setLayout(new GridLayout(3, 1)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); } }); headerLabel = new Label(); headerLabel.setAlignment(Label.CENTER); statusLabel = new Label(); statusLabel.setAlignment(Label.CENTER); statusLabel.setSize(350,100); controlPanel = new Panel(); controlPanel.setLayout(new FlowLayout()); mainFrame.add(headerLabel); mainFrame.add(controlPanel); mainFrame.add(statusLabel); mainFrame.setVisible(true); } private void showLabelDemo(){ headerLabel.setText("Control in action: Label"); Label label = new Label(); label.setText("Welcome to TutorialsPoint AWT Tutorial."); label.setAlignment(Label.CENTER); label.setBackground(Color.GRAY); label.setForeground(Color.WHITE); controlPanel.add(label); mainFrame.setVisible(true); } }
  • 11. SWING Controls  Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front End/GUI Applications.  It is build on top of AWT API and acts as a replacement of AWT API, since it has almost every control corresponding to AWT controls.  Swing component follows a Model-View-Controller architecture to fulfill the following criterias.  A single API is to be sufficient to support multiple look and feel.  API is to be model driven so that the highest level API is not required to have data.  API is to use the Java Bean model so that Builder Tools and IDE can provide better services to the developers for use.  Swing API architecture follows loosely based MVC architecture in the following manner.  Model represents component's data.  View represents visual representation of the component's data.  Controller takes the input from the user on the view and reflects the changes in Component's data.  Swing component has Model as a seperate element, while the View and Controller part are clubbed in the User Interface elements. Because of which, Swing has a pluggable look-and-feel architecture.
  • 12. SWING Controls  Swing Features  Light Weight − Swing components are independent of native Operating System's API as Swing API controls are rendered mostly using pure JAVA code instead of underlying operating system calls.  Rich Controls − Swing provides a rich set of advanced controls like Tree, TabbedPane, slider, colorpicker, and table controls.  Highly Customizable − Swing controls can be customized in a very easy way as visual apperance is independent of internal representation.  Pluggable look-and-feel − SWING based GUI Application look and feel can be changed at run-time, based on available values.  For more information : https://docs.oracle.com/javase/8/docs/api/index.html?javax/swing/package- summary.html
  • 13. SWING Controls  Every user interface considers the following three main aspects −  UI Elements − These are the core visual elements the user eventually sees and interacts with. GWT provides a huge list of widely used and common elements varying from basic to complex  Layouts − They define how UI elements should be organized on the screen and provide a final look and feel to the GUI (Graphical User Interface).  Behavior − These are the events which occur when the user interacts with UI elements.
  • 14. SWING Controls - Class & Description Component - A Component is the abstract base class for the non menu user-interface controls of SWING. Component represents an object with graphical representation Container - A Container is a component that can contain other SWING components Jcomponent - A JComponent is a base class for all SWING UI components. In order to use a SWING component that inherits from JComponent, the component must be in a containment hierarchy whose root is a top-level SWING container Jlabel – A JLabel object is a component for placing text in a container. Jbutton - This class creates a labeled button. JColorChooser - A JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color. JCheck Box - A JCheckBox is a graphical component that can be in either an on(true) or off (false) state. JRadioButton - The JRadioButton class is a graphical component that can be in either an on (true) or off (false) state. in a group. Jlist - A JList component presents the user with a scrolling list of text items. JComboBox - A JComboBox component presents the user with a to show up menu of choices. JTextField - A JTextField object is a text component that allows for the editing of a single line of text. JPasswordField - A JPasswordField object is a text component specialized for password entry. JTextArea - A JTextArea object is a text component that allows editing of a multiple lines of text. ImageIcon - A ImageIcon control is an implementation of the Icon interface that paints Icons from Images Jscrollbar - A Scrollbar control represents a scroll bar component in order to enable the user to select from range of values. JOptionPane - JOptionPane provides set of standard dialog boxes that prompt users for a value or informs them of something. JFileChooser - A JFileChooser control represents a dialog window from which the user can select a file. JProgressBar - As the task progresses towards completion, the progress bar displays the task's percentage of completion. Jslider - A JSlider lets the user graphically select a value by sliding a knob within a bounded interval.
  • 15. SWING Controls import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingControlDemo { private JFrame mainFrame; private JLabel headerLabel; private JLabel statusLabel; private JPanel controlPanel; public SwingControlDemo(){ prepareGUI(); } public static void main(String[] args){ SwingControlDemo swingControlDemo = new SwingControlDemo(); swingControlDemo.showButtonDemo(); } private void prepareGUI(){ mainFrame = new JFrame("Java Swing Examples"); mainFrame.setSize(400,400); mainFrame.setLayout(new GridLayout(3, 1)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); } }); headerLabel = new JLabel("", JLabel.CENTER); statusLabel = new JLabel("",JLabel.CENTER); statusLabel.setSize(350,100); controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); mainFrame.add(headerLabel); private static ImageIcon createImageIcon(String path, String description) { java.net.URL imgURL = SwingControlDemo.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } else { System.err.println("Couldn't find file: " + path); return null; } } private void showButtonDemo(){ headerLabel.setText("Control in action: Button"); //resources folder should be inside SWING folder. ImageIcon icon = createImageIcon("/resources/java_icon.png","Java"); JButton okButton = new JButton("OK"); JButton javaButton = new JButton("Submit", icon); JButton cancelButton = new JButton("Cancel", icon); cancelButton.setHorizontalTextPosition(SwingConstants.LEFT); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { statusLabel.setText("Ok Button clicked."); } }); javaButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { statusLabel.setText("Submit Button clicked."); } }); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { statusLabel.setText("Cancel Button clicked."); } });