static public void graficar(

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.
Drawing in a frame – Java GUI
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Övning 5. Repetition klasser class Rektangel { private static int antal = 0; private double längd; private double bredd; public Rektangel(double l, double.
Event Handling Feb 14, Event Model Revisited zRecall that a component can fire an event. zEach type of event is defined as a distinct class. zAn.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Java GUI Libraries Swing Programming. Swing Components Swing is a collection of libraries that contains primitive widgets or controls used for designing.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 9 Object Oriented Programming in Java Advanced Topics Abstract Windowing.
© L.Lúcio, An example GUI in Java n Two graphic libraries in Java u AWT u Swing n Swing is more recent than AWT: u Built on top of AWT classes;
LayoutManager, J 1 Layout Manager. LayoutManager, J 2 Layout Manager To each UI container there is a layout manager (an object). When you add a component.
Buttons. Appearance of buttons A button has one of three appearances: Disabled by your program Enabled by your program Enabled by your program and pressed.
1 lecture 12Lecture 13 Event Handling (cont.) Overview  Handling Window Events.  Event Adapters Revisited.  Introduction to Components and Containers.
Layout Mangers CSC 171 FALL 2001 LECTURE 14. History: The Transistor William Shockley, John Bardeen, and Walter Brattain invent the transfer resistance.
James Tam An introduction into HCI: Task-Centered System Design An Introduction To Graphical User Interfaces The event-driven model Building a simple.
Java GUI building with the AWT. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many.
Lesson 35: Review of the Java GUI. The JFrame, Container and JButton.
CSTP WS00CS423 (cotter)1 Java Applets Objective: Learn how to develop Java programs that interact with users through a Web browser.
Graphical User Interface CSI 1101 N. El Kadri. Plan - agenda Graphical components Model-View-Controller Observer/Observable.
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Intro to Java Java Applications Swing Class Graphics.
Java GUI building with Swing. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Java Programming 1 Java Programming II Events, AWT, and Swing.
C13a, AWT Create, display, facilitate user interaction with window objects software framework: a way of structuring generic solutions to common problems.
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
Event Handling Mohanraj S AP / IT Angel College of Engg & Tech.,
CSTP FS99CS423 (cotter)1 Java Graphics java.awt.*;
GUI 프로그래밍과 AWT(2) 컴퓨터 공학실험 (I) 인공지능 연구실. 2 AWT Event Model  Java 의 Event Model 1.Event : 사용자가 Program 에 가한 행동 2.Event Source : Event 가 일어난 근원 3.Event.
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
Swing GUI Components You can create graphics components to place on your applet using classes available in the Swing package ( javax.swing ) Class names.
Chapter 12 1 TOPIC 13B l Buttons and Action Listeners Window Interfaces Using Swing Objects.
Layout Managers Arranges and lays out the GUI components on a container.
Introduction to GUI Programming with Java Graphical User Interfaces With AWT and Swing Towson University *Ref:
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
1 Class 6. 2 Objectives Objectives Enable your applications to perform actions in response to JButton clicks Get the text the user enters in a textfield.
Java Applet Basics (2). The Body Mass Index Calculator.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Kim B. Bruce, Andrea Danyluk & Tom Murtagh Williams College † Partially supported by NSF CCLI grant DUE Java: An Eventful Approach An innovative.
Java Model-View-Controller. Design Patterns The hard problem in O-O programming is deciding what objects to have, and what their responsibilities are.
A cannon game ?. Simple version angle from command line, one shot only Coordinate system is “upside-down”: Use dy(int) method to transform y coordinate:
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
1 IM103 week 8 (C&K ch17, p412) Advanced graphic programming Learning objectives By the end of this chapter you should be able to:  create dialogue windows.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Event Handling CS 21a: Introduction to Computing I First Semester,
C13b, AWT cont.. Panel Container that acts like a Component Can be added into other components (like Frames, other Panels) private Panel makeScrollBars()
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
Chapter 11: Threaded Programs Situations where the program is following multiple execution paths (how to stop one?) Thread: a line of execution Thread.
MIT AITI 2004 Swing Event Model Lecture 17. The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the.
AWT Vs SWING. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses.
Chapter 6 Building Java GUIs. MVC Model View Controller The model passes its data to the view for rendering The view determines which events are passed.
Design Applet based java program to find the area and perimeter of a rectangle given its length and width. Java GUI.
Modular Event Handling
Introduction Many Java application use a graphical user interface or GUI (pronounced “gooey”). A GUI is a graphical window or windows that provide interaction.
GUI- Model-View-Controller
CSC 205 Programming II Lecture 5 AWT - I.
Graphical User Interfaces
INFSY 547: WEB-Based Technologies
PORTAFOLIO DE EVIDENCIAS
TOPICOS AVANZADOS de programación
INSTITUTO TÉCNOLOGICO SUPERIOR DE LIBRES CARLA PATRICIA VIVANCO GARCÍA TOPICOS AVANZADOS DE PROGRAMACIÓN ELIZABETH DÍAZ OREA.
Ellen Walker Hiram College
Event Handling CS 21a: Introduction to Computing I
MVC Paradigm The MVC paradigm breaks applications or interfaces into three parts: the model, the view, and the controller. A --> 25 % B --> 60 % C -->
Course Outcomes of Advanced Java Programming AJP (17625, C603)
어서와 Java는 처음이지! 제13장 실전프로젝트.
Programming Graphical User Interface (GUI)
GUI building with the AWT
Graphical User Interface
GUI- Model-View-Controller
Presentation transcript:

static public void graficar( Funcion f, //f: referencia a objeto int n, //nº de puntos double a, double b,//extremos intervalo Graphics g, //objeto gráfico int W, int H) //ancho y alto de g con interface Funcion { public double valor(double x); }

import java.awt.*; import java.awt.event.*; class SenoCoseno extends Frame implements ActionListener { static public void main(String[]args) new SenoCoseno().show(); } private int W=300, H=200; private Canvas cv=new Canvas(); private TextField puntos=new TextField(); Private Label pregunta=new Label(“nºpuntos?”); private Button quit=new Button(“quit”), seno=new Button(“seno”), coseno=new Button(“coseno”);

public SenoCoseno() { //diagramar panel Panel p=new Panel(); p.setLayout(new Gridlayout(1,5)); p.add(seno); p.add(coseno): p.add(pregunta); p.add(puntos); p.add(quit); //diagramar ventana setSize(W,H+25); setLayout(new BorderLayout()); add(”Center”,cv); add(”South”,p); //activar escuchadores quit.addActionListener(this); seno.addActionListener(this); coseno.addActionListener(this); }

public void actionPerformed (ActionEvent x) { if(x.getSource()==quit) System.exit(0); int n=Integer.parseInt(puntos.getText()); Graphics g=cv.getGraphics(); if(x.getSource()==seno) graficar(new Seno(),n,0,2*Math.PI,g,W,H); else graficar(new Coseno(),n,0,2*Math.PI,g,W,H); }