Java Programming Language (6)

Slides:



Advertisements
Similar presentations
Programming in Java; Instructor:John Punin Graphics and Graphical User Interfaces1 Programming in Java Graphics and Graphical User Interfaces.
Advertisements

Event Handling.
Inner Classes in Java CMSC 432 Shon Vick. 2 Conceptual Structure package p 1 class A 1 class A 2... class A n... package n class A 1 class A 2... class.
Jan Event Handling -1.1 Yangjun Chen Dept. Business Computing University of Winnipeg.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION GUI & (A LITTLE ON) DESIGN PATTERNS III Autumn 2011.
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.
Applet Class Hierarchy. Applet Methods called by the system public void init() When the applet is first loaded. Do initialization here. public void start()
Graphics Programming with Inheritance Template pattern (Chap 6, se SceneEditor)
OOP Java1 Event Handling Overview Listeners, Adapters and Event Sources Inner classes Event Handling Details Applets and GUI Applications Event.
1 Gui Programming (Part I) Graphical User Interfaces (Part I) l Introduction to events. l A Brief history. l Event sources and listeners. l The delegation.
Intermediate Java1 An example that uses inner classes Week Four Continued.
GUI. Swing Class Hierarchy Swing Components Swing Conatiners  JFrame – top-level window to store components.
EVENTS CSC 171 FALL 2004 LECTURE 16. “Traditional” Input In console applications, user input is under control of the program The program asks the user.
PROGRAMMING GRAPHICAL USER INTERFACES Lecture 21 JAVA GUI BASICS Basic Java GUI Components –java.awt.Component, java.awt.Container, javax.swing.JComponent,
GUI Event Handling Nithya Raman. What is an Event? GUI components communicate with the rest of the applications through events. The source of an event.
28-Aug-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic : Event Handling – GUI Part II.
Mouse Events. Handling Mouse Events Java provides two listener interfaces to handle mouse events: MouseListener;  MouseListener;  MouseMotionListener.
1 CSE 331 More Events (Mouse, Keyboard, Window, Focus, Change, Document...) slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D.
More Event Handling Adapters Anonymous Listeners Pop menus Validating User Input.
Cs884(Prasad)java12AWT1 Abstract Windowing Toolkit Support for Graphical User Interface (Event-driven programming)
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
CSE 501N Fall ‘09 20: Event Handling and Inner Classes 17 November 2009 Nick Leidenfrost.
SD2071 Games Programming Abstraction, inheritance and interfaces Exceptions Two dimensional arrays Java collections framework Files Aaron Kans.
COMP 321 Week 2. Outline Event-Driven Programming Events, Event Sources, Event Listeners Button and Timer Events Mouse Events, Adapters.
Omer Boyaci.  GUIs are event driven.  When the user interacts with a GUI component, the interaction—known as an event—drives the program to perform.
For (int i = 1; i
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.
Introduction to Java Programming
Universidad Nacional de Colombia Facultad de Ingeniería Departamento de Sistemas ertificación en AVA.
CMSC 341 Making Java GUIs Functional. 09/29/2007 CMSC 341 Events 2 More on Swing Great Swing demo at /demos/jfc/SwingSet2/SwingSet2Plugin.html.
© Marty Hall, Larry Brown Web core programming 1 Handling Mouse and Keyboard Events.
Object Oriented Programming.  Interface  Event Handling.
Event Handling. The signals that a program receives from the operating system as a result of the actions are called events. A window based program is.
Index Event Handling Events Event Source Event Listener Event Classes Action Event Class Adjustment event Class Event Source Event Listener Interface Using.
GUI DYNAMICS Lecture 11 CS2110 – Fall GUI Statics and GUI Dynamics  Statics: what’s drawn on the screen  Components buttons, labels, lists, sliders,
Events in JAVA Needed for Applets and GUI based programs. Applet uses GUI to interact with user. Most of the events are generated by Mouse, Keyboard.
Java GUI COMP 401 Fall 2014 Lecture 16 10/20/2014.
Event-Driven Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CS Lecture 04 Mice Lynda Thomas
1 Event Handling – Lecture 4 Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
Chapter 6: Events in Java 1.0 Model –Event class –selecting component to handle –handleEvent method –helper methods (action, keyUp, mouseUp, etc.) 1.1.
2/17/2016 DEPT OF CSE 1 EVENT HANDLING. 2/17/2016 DEPT OF CSE 2 Event handling is at the core of successful applet programming There are several types.
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.
Event Listeners ActionListener –button,list AdjustmentListener-scroll bar ComponentListener-when component hidden…. ContainerListener-comp added or removed.
Institute of Ambient Intelligence 2009, Choi, Namseok, Dongseo Univ., Java 기초 ( 컴포넌트와 이벤트 처리 프로그래밍 ) Choi,
CSI 3125, Preliminaries, page 1 Event Handling. CSI 3125, Preliminaries, page 2 Event Handling An Event Change in the state of an object is known as event.
Mouse Events GUI. Types of Events  Below, are some of the many kinds of events, swing components generate. Act causing EventListener Type User clicks.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
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.
Dept. of CSIE, National University of Tainan 10/21/2012 Responding to User Input.
EVENT HANDLING 10/8/2017.
Events and Event Handling
Lecture 8 Object Oriented Programming Using Java
Programming in Java, 2e Sachin Malhotra Saurabh Choudhary.
Chapter 12 Event-Driven Programming
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
Event Handling Chapter 2 Objectives
Unit 5 Applets: Applet class, Applet structure, An example of Applet, Applet life Cycle, Event Delagation Model, Java.awt.even description, Sources of.
GUI III IS
Programming in Java Event Handling
GUI Event Handling Nithya Raman.
GUI Programming III: Events
CSE Software Engineering Fall 1999 Updated by J. Brown
Event-driven programming for GUI
Unit I: Chapter 1 Event handling.
Events, Event Handlers, and Threads
Programming Graphical User Interface (GUI)
Making Java GUIs Functional
Chapter 6 Inheritance.
Presentation transcript:

Java Programming Language (6) Dong In Shin DCS lab Seoul National University

dishin@dcslab.snu.ac.kr

AWT event handling model java.awt.event package AWT event는 1개의 event wait queue에서 대기 AWT event source 로 배분 여러 개의 event listener가 하나의 event source를 listen 편리한 처리를 위해 inner class를 이용 dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

Adapter class Event handling method 중 일부만을 정의하고자 할 때, 보다 간편한 event handle programming Component Adapter ContainerAdapter WindowAdapter MouseAdapter KeyAdapter dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

Event handle interface & AWT event class AWT event handling interface java.util.Eventlistener의 하위 interface java.awt.event package Event handling interface가 처리할 수 있는 AWT event class 가 정의 AWT event class java.awt.AWTevent의 하위 class java.awt.event Event 종류에 맞는 정보를 유지하기 위한 method 와 field 유지 dishin@dcslab.snu.ac.kr

Event handle interface & AWT event class dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

Event handler의 등록 dishin@dcslab.snu.ac.kr

WindowEvent class dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

ActionEvent class ActionListener interface ActionEvent actionPerformed(ActionEvent) : 연관된 명령을 실행 ActionEvent String actionCommand Int modifiers SHIFT_MASK, CTRL_MASK, ALT_MASK, META_MASK dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

InputEvent 와 MouseEvent class MouseEvent, KeyEvent MouseListener interface mousePressed(MouseEvent) mouseReleased(MouseEvent) mouseClicked(MouseEvent) mouseEntered(MouseEvent) mouseExited(MouseEvent) MouseMotionListener interface mouseMoved(MouseEvent) mouseDragged(MouseEvent) dishin@dcslab.snu.ac.kr

InputEvent 와 MouseEvent class long when int modifiers CTRL_MASK, SHIFT_MASK, ALT_MASK, META_MASK… boolean isControlDown() boolean isShiftDown() boolean isAltDown() dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr

dishin@dcslab.snu.ac.kr