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

Similar documents
Graphical Interfaces

Graphical Interfaces

Interacción con GUIs

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

1 of :32:42

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

Chapter 1 GUI Applications

CSE 8B Intro to CS: Java

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

Chapter 14. More Swing

Programming Languages and Techniques (CIS120e)

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

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

Functors - Objects That Act Like Functions

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

The AWT Event Model 9

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

Advanced Java Programming (17625) Event Handling. 20 Marks

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

BM214E Object Oriented Programming Lecture 13

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

GUI Programming: Swing and Event Handling

Swing II CHAPTER WINDOW LISTENERS 1034 Example: A Window Listener Inner Class 1036 The dispose Method 1040 The WindowAdapter Class 1041

Swing II Window Listeners Icons and Scroll Bars The Graphics Class Colors 1044

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

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

Java Programming Unit 6. Inner Classes. Intro to Apples. Installing Apache Tomcat Server.

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

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

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

Inheritance (continued) Inheritance

Programming Language Concepts: Lecture 8

JAVA NOTES GRAPHICAL USER INTERFACES

VK Computer Games Game Development Fundamentals

Propedéutico de Programación

Java AWT Windows, Text, & Graphics

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

Apéndice A. Código fuente de aplicación desarrollada para probar. implementación de IPv6

The Design and Implementation of Multimedia Software

GUÍAS COMPLEMENTARIAS

The Java Swing Toolkit

Default Route de la configuración en el EIGRP

JAVA NOTES GRAPHICAL USER INTERFACES

PRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES

Arrays, Exception Handling, Interfaces, Introduction To Swing

Example 3-1. Password Validation

(Incomplete) History of GUIs

AWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.

AWT CHOICE CLASS. Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu.

SOME BACKGROUND ON DESIGN PATTERNS

Java 6. Network programming

Building Graphical User Interfaces. Overview

Object Oriented Programming. I. Object Based Programming II. Object Oriented Programming

6.092 Introduction to Software Engineering in Java January (IAP) 2009

Laborator 2 Aplicatii Java

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling

Resumen. Una sola cámara Robot móvil Visión computacional Resultados experimentales

Anexo A: Implementación pasarela SMS/SIP

AWT COLOR CLASS. Introduction. Class declaration. Field

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

Chapter 13 Lab Advanced GUI Applications

Programming Languages and Techniques (CIS120)

The colours used in architecture must be intense, logical and fertile. Los colores usados en arquitectura tiene que ser intensos, logicos y fértiles.

AWT WINDOW CLASS. The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager.

CSA 1019 Imperative and OO Programming

Building Graphical User Interfaces. GUI Principles

b) Use one of your methods to calculate the area of figure c.

AWT TEXTFIELD CLASS. Constructs a new empty text field with the specified number of columns.

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Propedéutico de Programación

Programming Languages and Techniques (CIS120)

Anexos. Diseño y construcción de un puente grúa automatizado de precisión

CERTIFICACION SAGE Enterprise Management (X3)

Laborator 3 Java. Introducere in programarea vizuala

AWT QUADCURVE2D CLASS

OCTOBEAM. LED Lighting Effect USER MANUAL / MANUAL DE USUARIO

!"# $ %&# %####' #&() % # # # #&* # ## +, # -

Curs 6. GUI Swing. POO - curs 6

Basicsof. JavaGUI and SWING

Create Extensions App inventor 2 Build Extensions App Inventor, easy tutorial - Juan Antonio Villalpando

Administrivia. CSSS Movie Night: Zombieland & Iron Man Date: Thurs., Mar 11 Time: 6 10 pm Location: DMP 310 Free pop & popcorn for every attendee!

AWT LIST CLASS. The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items.

dit UPM Tema 3: Concurrencia /clásicos /java Análisis y diseño de software José A. Mañas

Autor: Mary Luz Roa SUPPORT GUIDE FOURTH TERM

RISC Processor Simulator (SRC) INEL 4215: Computer Architecture and Organization Feb 14, 2005

Table 3.1. Java Programs. Applets normally run in a virtual machine inside of a WWW browser. 1 They are executed

Code zum Betreuten Programmieren vom , Blatt 10 Serialisierung und GUI

Theory Test 3A. University of Cape Town ~ Department of Computer Science. Computer Science 1016S ~ For Official Use

PROGRAMACIÓN ORIENTADA A OBJETOS

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the

CS193k, Stanford Handout #16

Eclipsing Your IDE. Figure 1 The first Eclipse screen.

3 Events and Listeners

Window Interfaces Using Swing Objects

Event driven Programming

Letter. Activity. Tips. Use sides and angles to name this quadrilateral.

A sample print out is: is is -11 key entered was: w

Part 3: Graphical User Interface (GUI) & Java Applets

Important Change to the Year End W2 Process

Transcription:

FORMAS DE IMPLEMENTAR LOS OYENTES A).- El oyente en una clase independiente con el constructor con un argumento y usando el método getactioncommand. public class VentanaOyente extends Frame{ private Oyente oyente; public VentanaOyente(){ super("ventana con oyente"); public void settipocara(int tipocara){ this.tipocara = tipocara; public int gettipocara(){ return tipocara; oyente = new Oyente(this); boton1.addactionlistener(oyente); boton2.addactionlistener(oyente); Rafael Rivera López 1

class Oyente implements ActionListener{ private VentanaOyente ventana; public Oyente(VentanaOyente origen){ this.ventana = origen; public void actionperformed(actionevent e) { String origen = e.getactioncommand(); if(origen.equals("carita Feliz")) ventana.settipocara(1); ventana.settipocara(2); ventana. B).- El oyente en una clase independiente con el constructor con dos argumentos MiPaint.java y OyenteBoton.java public class MiPaint extends Frame{ public MiPaint(){ super("uso del método paint"); Rafael Rivera López 2

public void settipocara(int tipocara){ this.tipocara = tipocara; OyenteBoton aboton1 = new OyenteBoton(1,this); OyenteBoton aboton2 = new OyenteBoton(2,this); boton1.addactionlistener(aboton1); boton2.addactionlistener(aboton2); public class OyenteBoton implements ActionListener{ private int valor; private MiPaint f; public OyenteBoton(int valor,mipaint f){ this.valor = valor; this.f = f; f.settipocara(valor); f. Rafael Rivera López 3

C).- La ventana es el oyente public class VentanaOyente extends Frame implements ActionListener{ public VentanaOyente(){ super("ventana como oyente"); boton1.addactionlistener(this); boton2.addactionlistener(this); if(e.getsource()==boton1) tipocara=1; tipocara=2; Rafael Rivera López 4

D).- El oyente es una clase interna public class VentanaOyenteInterno extends Frame{ public VentanaOyenteInterno(){ super("ventana con Oyente Interno"); OyenteBoton aboton1 = new OyenteBoton(1); OyenteBoton aboton2 = new OyenteBoton(2); boton1.addactionlistener(aboton1); boton2.addactionlistener(aboton2); Rafael Rivera López 5

class OyenteBoton implements ActionListener{ private int valor; public OyenteBoton(int valor){ this.valor = valor; tipocara = valor; E).- La ventana es el oyente de varios eventos public class VentanaOyente extends Frame implements ActionListener, WindowListener{ public VentanaOyente(){ super("ventana como oyente"); boton1.addactionlistener(this); boton2.addactionlistener(this); addwindowlistener(this); Rafael Rivera López 6

if(e.getsource()==boton1) tipocara=1; tipocara=2; public void windowopened(windowevent e) { public void windowclosing(windowevent e) { System.exit(0); public void windowclosed(windowevent e) { public void windowiconified(windowevent e) { public void windowdeiconified(windowevent e) { public void windowactivated(windowevent e) { public void windowdeactivated(windowevent e) { F).- El oyente es una clase interna anónima public class VentanaOyente extends Frame{ public VentanaOyente(){ super("ventana como oyente"); Rafael Rivera López 7

boton1.addactionlistener(new ActionListener(){ tipocara=1; ); boton2.addactionlistener(new ActionListener(){ tipocara=2; ); addwindowlistener(new WindowListener(){ public void windowopened(windowevent e) { public void windowclosing(windowevent e) { System.exit(0); public void windowclosed(windowevent e) { public void windowiconified(windowevent e) { public void windowdeiconified(windowevent e) { public void windowactivated(windowevent e) { public void windowdeactivated(windowevent e) { ); Rafael Rivera López 8

G).- El oyente a través de clases Adaptadoras public class VentanaOyente extends Frame{ public VentanaOyente(){ super("ventana como oyente"); boton1.addactionlistener(new ActionListener(){ tipocara=1; ); boton2.addactionlistener(new ActionListener(){ tipocara=2; Rafael Rivera López 9

); addwindowlistener(new WindowAdapter(){ public void windowclosing(windowevent e) { System.exit(0); ); Rafael Rivera López 10