Interacción con GUIs

Similar documents
The AWT Event Model 9

Advanced Java Programming (17625) Event Handling. 20 Marks

11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Handling Mouse and Keyboard Events

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

GUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)

GUI Programming: Swing and Event Handling

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is

Dr. Hikmat A. M. AbdelJaber

FORMAS DE IMPLEMENTAR LOS OYENTES. A).- El oyente en una clase independiente con el constructor con un argumento y usando el método getactioncommand.

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

IPM 12/13 P4 Handling Events in AWT

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Java AWT Windows, Text, & Graphics

BM214E Object Oriented Programming Lecture 13

Graphical Interfaces

UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.

COMPSCI 230. Software Design and Construction. Swing

Graphical Interfaces

OBJECT ORIENTED PROGRAMMING. Java GUI part 1 Loredana STANCIU Room B616

Computer Programming Java AWT Lab 18

GUI Design. Overview of Part 1 of the Course. Overview of Java GUI Programming

Assignment No 2. Year: Dept.: ComputerTech. Sanjivani Rural Education Society s Sanjivani KBP Polytechnic, Kopargaon

Event Driven Programming

Chapter 1 GUI Applications

10/16/2008. CSG 170 Round 5. Prof. Timothy Bickmore. User Analysis Task Analysis (6) Problem Scenarios (3)

GUI Event Handlers (Part I)

Išdėstymai. Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras.

public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety();

GUI in Java TalentHome Solutions

Course: CMPT 101/104 E.100 Thursday, November 23, 2000

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

กล ม API ท ใช. Programming Graphical User Interface (GUI) Containers and Components 22/05/60

Which of the following syntax used to attach an input stream to console?

SD Module-1 Advanced JAVA

COURSE 7 PROGRAMMING III OOP. JAVA LANGUAGE

SD Module-1 Advanced JAVA. Assignment No. 4

(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

3 Events and Listeners

G51PRG: Introduction to Programming Second semester Applets and graphics

JAVA. Object Oriented Programming with. M.T. Somashekara D.S.Guru K.S. Manjunatha

GUI. Overview: JFC - Java Foundation Classes. JFC: Java Foundation Classes. Graphical User Interfaces. GUI-based Applications. containment hierarchy:

Programming Mobile Devices J2SE GUI

Bean Communication. COMP434B Software Design. Bean Communication. Bean Communication. Bean Communication. Bean Communication

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).

GUI Event Handlers (Part II)

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything.

Programming Languages and Techniques (CIS120e)

AP Computer Science Unit 13. Still More Graphics and Animation.

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

14.2 Java s New Nimbus Look-and-Feel 551 Sample GUI: The SwingSet3 Demo Application As an example of a GUI, consider Fig. 14.1, which shows the SwingS

user-friendly and easy to use.

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

Graphical User Interfaces 2

Graphical User Interfaces 2

1 of :32:42

2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING

Graphical User Interfaces 2

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Together, the appearance and how user interacts with the program are known as the program look and feel.

Maharashtra State Board of Technical Education

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

GUI 4.1 GUI GUI MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */

CSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

Programmierpraktikum

University of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ November Exam

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place.

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3

The Abstract Window Toolkit

CS11 Java. Fall Lecture 3

Packages: Putting Classes Together

Advanced Java Unit 6: Review of Graphics and Events

Lecture 5: Java Graphics

CS211 GUI Dynamics. Announcements. Motivation/Overview. Example Revisted

Lecture 3: Java Graphics & Events

Code zum Betreuten Programmieren vom , Blatt 10 Serialisierung und GUI

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

The AWT Component Library 10

Functors - Objects That Act Like Functions

cs Java: lecture #5

Event driven Programming

CSA 1019 Imperative and OO Programming

SAMPLE EXAM Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009

CSE 8B Intro to CS: Java

Java 2: The Complete Reference, Fourth Edition

II 12, JFileChooser. , 2. SolidEllipse ( 2), PolyLine.java ( 3). Draw.java

PIC 20A GUI with swing

Chapter 13 - Graphical User Interface Components: Part 1

Java Foundations John Lewis Peter DePasquale Joe Chase Third Edition

Java: Graphical User Interfaces (GUI)

H212 Introduction to Software Systems Honors

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

PESIT Bangalore South Campus

AP CS Unit 12: Drawing and Mouse Events

CSIS 10A Assignment 14 SOLUTIONS

Unit 7: Event driven programming

Transcription:

Interacción con GUIs

Delegation Event Model Fuente EVENTO Oyente suscripción Fuente Oyente suscripción EVENTO Adaptador EVENTO

java.lang.object java.util.eventobject java.awt.awtevent java.awt.event. ActionEvent AdjustmentEvent ComponentEvent ItemEvent TextEvent FocusEvent InputEvent ContainerEvent WindowEvent KeyEvent MouseEvent

ActionListener ItemListener MouseListener MouseMotionListener KeyListener FocusListener AdjustmentListener ComponentListener WindowListener ContainerListener TextListener actionperformed(actionevent) itemstatechanged(itemevent) mousepressed) mousereleased) mouseentered) mouseexited) mouseclicked) mousedragged) mousemoved) keypressed(keyevent) keyreleased(keyevent) keytyped(keyevent) focusgained(focusevent) focuslost(focusevent) adjustmentvaluechanged(adjustmentevent) componentmoved(componentevent) componenthidden(componentevent) componentresized(componentevent) componentshown(componentevent) windowclosing(windowevent) windowopened(windowevent) windowiconified(windowevent) windowdeiconified(windowevent) windowclosed(windowevent) windowactivated(windowevent) windowdeactivated(windowevent) componentadded(containerevent) componentadded(containerevent) textvaluechanged(textevent)

import import java.awt.*; java.awt.*; DelegationEvenModeTest DelegationEvenModeTest FrameEmisor FrameEmisor extends extends Frame Frame Button Button boton; boton; static static main(string[ main(string[ ] ] args) args) FrameEmisor() FrameEmisor() boton boton = = new new Button Button ("Púlsame"); FrameEmisor ("Púlsame"); FrameEmisor fe=new fe=new FrameEmisor(); FrameEmisor(); add add (boton); (boton); fr=new fr=new (fe); (fe); setvisible(true); setvisible(true); fr2=new fr2=new (fe); (fe); pack(); pack(); import import java.awt.*; java.awt.*; import import java.awt.event.*; java.awt.event.*; extends extends java.awt.frame java.awt.frame implements implements MouseListener MouseListener private private int int toques=0; toques=0; Label Label etiqueta etiqueta (FrameEmisor (FrameEmisor f) f) etiqueta etiqueta = = new new Label Label ("El ("El botón botón no no se se ha ha pulsado pulsado ni ni una una sola sola vez"); vez"); add add (etiqueta); (etiqueta); setvisible(true); setvisible(true); pack(); pack(); MouseListener f.boton.addmouselistener(this); f.boton.addmouselistener(this); Suscripción mouseclicked mouseclicked (java.awt.event.mouseevent (java.awt.event.mouseevent etiqueta.settext etiqueta.settext ("El ("El botón botón se se ha ha pulsado pulsado "+(++toques)+((toques==1)?" "+(++toques)+((toques==1)?" vez":" vez":" veces")); veces")); mousepressed mousepressed mousereleased mousereleased mouseentered mouseentered mouseexited mouseexited

import java.awt.*; EjemploMensaje extends java.awt.panel Listener EjemploMensaje() initcomponents (); private initcomponents () label1 = new java.awt.label (); panel1 = new java.awt.panel (); button1 = new java.awt.button (); setlayout (new java.awt.borderlayout ()); Source label1.setfont (new java.awt.font ("Book Antiqua", 2, 14)); label1.setname ("label6"); label1.setbackground (new java.awt.color (204, 204, 204)); label1.setforeground (java.awt.color.black); label1.settext ("El bot\u00f3n no se ha pulsado ni una sola vez"); label1.setalignment (java.awt.label.center); add (label1, java.awt.borderlayout.center); panel1.setfont (new java.awt.font ("Dialog", 0, 11)); panel1.setname ("panel8"); panel1.setbackground (new java.awt.color (204, 204, 204)); panel1.setforeground (java.awt.color.black); button1.setfont (new java.awt.font ("Arial", 1, 14)); button1.setlabel ("P\u00falsame"); button1.setname ("button6"); button1.setbackground (new java.awt.color (255, 0, 51)); button1.setforeground (java.awt.color.white); (continúa...)

Source button1.addmouselistener ( nuevo objeto MouseAdapter definido aquí mismo ); Adapter sin nombre button1.addmouselistener (new java.awt.event.mouseadapter () mouseclicked (java.awt.event.mouseevent button1mouseclicked (; ); El oyente del adapter es el panel1.add (button1); propio Panel add (panel1, java.awt.borderlayout.north); private button1mouseclicked (java.awt.event.mouseevent label1.settext ("El botón se ha pulsado "+(++toques)+((toques==1)?" vez":" veces")); private java.awt.label label1; private java.awt.panel panel1; private java.awt.button button1; private int toques=0; button1 Rutina oyente del adaptador em1 (EjemploMensaje) ewt Sin nombre ewt

FrameTEst extends java.awt.frame FrameTEst() initcomponents (); ejm=new EjemploMensaje(); add(ejm); pack (); private initcomponents () addwindowlistener (new java.awt.event.windowadapter () windowclosing (java.awt.event.windowevent exitform (; ); private exitform(java.awt.event.windowevent System.exit (0); static main (String args[]) new FrameTEst ().show (); EjemploMensaje ejm;