Welcome To java www.profajaypashankar.com.

Slides:



Advertisements
Similar presentations
1 Graphical User Interface (GUI) Applications Abstract Windowing Toolkit (AWT) Events Handling Applets.
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
F27SB2 Programming Languages
Jan Event Handling -1.1 Yangjun Chen Dept. Business Computing University of Winnipeg.
Events and the AWT The objectives of this chapter are: To understand the principles of the Java 1.1 event model To understand how the event model is used.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 16 Java Fundamentals Java2 Graphical User Interfaces.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Event Handling n Events: an event is an object that describes a state change in a source. n Event Sources: A source is an object that generates an event.
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
28-Aug-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic : Event Handling – GUI Part II.
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
GUI Programming in Java
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Introduction to Swing Components Chapter 14.  Part of the Java Foundation Classes (JFC)  Provides a rich set of GUI components  Used to create a Java.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Objectives of This Session
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
Graphical User Interface Components: Part 1 Chapter 11.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
1 Unit 5 GUI Aum Amriteshwaryai Namah. 2 Overview Shall learn how to reuse the graphics classes provided by Java for constructing Graphical User Interface.
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
CS Lecture 00 Swing overview and introduction Lynda Thomas
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 15 Java Fundamentals Java2 Graphical User Interfaces.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
CS GUI Frameworks CS 3331 Fall CS 3331 Outline MVC Model GUI components (widgets) Layout managers Handling events.
CS102 – GUI AWT & Swing Components & Containers, Layout Managers, Events & Listeners MVC design pattern. David Davenport.
Pravin Yannawar, DOCS, NMU Jalgaon. Basic Java : Event handling in AWT and Swing 2 Objectives of This Session Explain the Event handling mechanism & demonstrate.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
Event Handling. 2 GUIs are event driven –Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Object Oriented Programming.  Interface  Event Handling.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
GUI DYNAMICS Lecture 11 CS2110 – Fall GUI Statics and GUI Dynamics  Statics: what’s drawn on the screen  Components buttons, labels, lists, sliders,
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
Object-Oriented Application Frameworks CS 3331 Sections 8.1 & 8.3 of [Jia 03]
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
What Is an Event? Events – Objects that describe what happened Event sources – The generator of an event Event handlers – A method that receives an event.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
Sep 181 Example Program DemoTranslateEnglishGUI.java.
TENTH LECTURE Event and listener. Events and Listeners An event can be defined as a type of signal to the program that something has happened. The event.
GUI Programming in Java Hao Jiang Boston College April, 2009.
CSC 205 Programming II Lecture 5 AWT - I.
It attached with method ,class and interface etc…
Programming in Java, 2e Sachin Malhotra Saurabh Choudhary.
CHAPTER Reacting to the user.
Aum Amriteshwaryai Namah
Event Handling Chapter 2 Objectives
Java Events. Java Events Important definitions Overridden method Class vs. abstract class vs. interface Event Handling Definition Main components Windows.
Responding to Events Event Handling in Java
Abstract Window ToolKit (AWT)
CSE 114 – Computer Science I Event Programming
Ellen Walker Hiram College
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
AWT.
Graphics Programming - Frames
GUI building with the AWT
Lecture 4: Standard Java Graphics
Graphical User Interface
Presentation transcript:

Welcome To java www.profajaypashankar.com

Graphics and imaging tools, including shape, color, and font classes. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window Toolkit provides the connection between your application and the native GUI. AWT features include: A rich set of user interface components. A robust event-handling model. Graphics and imaging tools, including shape, color, and font classes. Layout managers, for flexible window layouts that don't depend on a particular window size or screen resolution. Data transfer classes, for cut-and-paste through the native platform clipboard. The AWT components depend on native code counterparts (called peers) to handle their functionality. Thus, these components are often called "heavyweight" components.

Swing Swing implements a set of GUI components that build on AWT technology and provide a pluggable look and feel. Swing is implemented entirely in the Java programming language, and is based on the JDK 1.1 Lightweight UI Framework. Swing features include: All the features of AWT. 100% Pure Java certified versions of the existing AWT component set (Button, Scrollbar, Label, etc.). A rich set of higher-level components (such as tree view, list box, and tabbed panes). Pure Java design, no reliance on peers. Pluggable Look and Feel. Swing components do not depend on peers to handle their functionality. Thus, these components are often called "lightweight" components.

AWT Swing AWT stands for Abstract Window Toolkit. Swing is a part of Java Foundation Class (JFC). AWT components are heavy weight. Swing components are light weight. AWT components are platform dependent so there look and feel changes according to OS. Swing components are platform independent so there look and feel remains constant. AWT components are not very good in look and feel as compared to Swing components. See the button in below image, its look is not good as button created using Swing.   Swing components are better in look and feel as compared to AWT. See the button in below image, its look is better than button created using AWT.

Commonly used Methods of Component class Description public void add(Component c) add a component on another component. public void setSize(int width,int height) sets size of the component. public void setLayout(LayoutManager m) sets the layout manager for the component. public void setVisible(boolean b) sets the visibility of the component. It is by default false.

Java Swing Examples There are two ways to create a frame: By creating the object of Frame class (association) By extending Frame class (inheritance) We can write the code of swing inside the main(), constructor or any other method.

Simple Java Swing Example import javax.swing.*;   public class FirstSwingExample {   public static void main(String[] args) {   JFrame f=new JFrame();//creating instance of JFrame              JButton b=new JButton("click");//creating instance of JButton   b.setBounds(130,100,100, 40);//x axis, y axis, width, height   f.add(b);//adding button in JFrame   f.setSize(400,500);//400 width and 500 height   f.setLayout(null);//using no layout managers   f.setVisible(true);//making the frame visible   }  

Event and Listener (Java Event Handling) Java Event classes and Listener interfaces Changing the state of an object is known as an event. For example, click on button, dragging mouse etc. The java.awt.event package provides many event classes and Listener interfaces for event handling.

Event Classes Listener Interfaces ActionEvent ActionListener MouseEvent MouseListener and MouseMotionListener MouseWheelEvent MouseWheelListener KeyEvent KeyListener ItemEvent ItemListener TextEvent TextListener AdjustmentEvent AdjustmentListener WindowEvent WindowListener ComponentEvent ComponentListener ContainerEvent ContainerListener FocusEvent FocusListener

Steps to perform Event Handling Following steps are required to perform event handling: Register the component with the Listener

Registration Methods For registering the component with the Listener, many classes provide the registration methods. For example: Button public void addActionListener(ActionListener a){} MenuItem TextField public void addTextListener(TextListener a){} TextArea Checkbox public void addItemListener(ItemListener a){} Choice List

Java Event Handling Code We can put the event handling code into one of the following places: Within class Other class Anonymous class