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

Size: px
Start display at page:

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

Transcription

1 Course: CMPT 101/104 E.100 Thursday, November 23, 2000 Lecture Overview: Week 12 Announcements Assignment 6 Expectations Understand Events and the Java Event Model Event Handlers Get mouse and text input in applications Frame Windows Adding interface component to frame windows To Do: Review Chapter 10 Read ahead: Chapter 12 1

2 Events DOS / Unix is kind of comforting but those days are over. With this kind of program the user can only do 1 thing in practice: type in commands or data. This is easy for a programmer to deal with. You can basically force the user to follow a pre-determined path of execution, step by step. For example, it is easy to enforce typical program logic for the Bank programs such as this. Start If the user enters 1, create a new account Else, if the user enters 7, Quit the program Else the input is invalid. Display error message. You can see that the user has one and only one option at any given time: keyboard input. Under these circumstances the programmer has it easy. 2

3 A typical window application is much more complex: There are multiple controls, each behaving in a different fashion. Some of the controls should only be enabled at certain times. Some of the controls should be populated with data at runtime. Which control does the user push, select, click, or activate? In what order? You probably cannot appreciate how much more complicated this sort of application is than the former, or how much design and testing that must go into these, nevertheless; the days of DOS are pretty well gone. The windows application is the majority of the work out there. 3

4 There are many different types of events: user types in data user clicks (double-clicks) on a mouse key: (left, right middle?) user presses a special key user resizes window user closes / minimizes window user tabs in or out of an text box etc The operating system will send messages to your program when an event occurs, though most events are generally ignored. To handle an event you need to create an event handler object from a special class. Before considering the complexities let us look at the Event Class Hierarchy: (p. 397): EventObject AWTEvent ActionEvent ComponentEvent InputEvent WindowEvent MouseEvent KeyEvent As you can see, one size does not fit all. If you want to handle events from a particular source you must create an object of the appropriate type. 4

5 Insert Addendum here. 5

6 Implementing the Interface The key to handling events is implementing the appropriate listener interface. For example, If you want to receive notifications about mouse events you need to implement the MouseListener interface. The Java Runtime sends you notification of the mouse events by calling the methods that are defined in the MouseListener Interface. That is why you must implement the interface: so that runtime can send you notification of mouse events by calling the methods that you have implemented. Here is that interface definition: public interface MousListener { // p 398 void mouseclicked(mouseevent event); void mouseentered(mouseevent event); void mouseexisted(mouseevent event); void mousepressed(mouseevent event); void mousereleased(mouseevent event); // You can probably guess what these are for. Notice: A parameter object of the MouseEvent class is sent to you with each method. This class has a set of methods that will make your life easier, such as the getx() and gety() methods that will allow you to determine where the mouse cursor is pointing at a given time. In order to get a feel for how these interfaces work, let us consider the applet created in the book: 6

7 You will see that this applet does little more than implement the mouse interface. import java.applet.applet; import java.awt.event.mouseevent; import java.awt.event.mouselistener; public class MouseSpyApplet extends Applet { public MouseSpyApplet() { // applet constructor MouseSpy listener = new MouseSpy(); addmouselistener(listener); // this tells the runtime where to send the event notifications class MouseSpy implements MouseListener { public void mouseclicked(mouseevent event) { System.out.println("Mouse clicked: x = " + event.getx() + " y = " + event.gety()); public void mouseentered(mouseevent event) { System.out.println("Mouse entered: x = " + event.getx() + " y = " + event.gety()); public void mouseexited(mouseevent event) { System.out.println("Mouse exited: x = " + event.getx() + " y = " + event.gety()); public void mousepressed(mouseevent event) { System.out.println("Mouse pressed: x = " + event.getx() + " y = " + event.gety()); public void mousereleased(mouseevent event) { System.out.println("Mouse released: x = " + event.getx() + " y = " + event.gety()); 7

8 Overriding Those Methods Overriding interface methods can be tedious, and they are always abstract, which means that you must override them all. Most of the time you don't want your class to do anything with a given method. For example, you generally won't want to do anything special when the mouse enters the area of the applet window, so your implementation would look something like this: public void mouseentered(mouseevent event) { // do nothing Because you rarely want to do anything with all or most of the methods of a given interface, some friendly soul at Sun created a special class that implements every listener interface with more than 1 method: the Adaptor classes. For example, there is a MouseAdapter class that implements that MouseListener interface with methods that do nothing. By creating a subclass of the appropriate Adaptor class (instead of implementing the listener interface from scratch) you only need to override the methods that you actually want to use, rather than having to override many unneeded methods as would be the case normally. // here is what the MouseAdaptor class looks like public class MouseAdapter implements MouseListener { public void mouseclicked(mouseevent event) { public void mouseentered(mouseevent event) { public void mouseexited(mouseevent event) { public void mousepressed(mouseevent event) { public void mousereleased(mouseevent event) { 8

9 Listeners as Inner Classes You can now create a class that receives event notifications from the Java Runtime. So what? In order to do something useful and interesting, listener objects need to interact with other objects, and those objects are usually private. This poses a problem. In the following example you will see that the listener class and the EggApplet class are completely separate. The listener object cannot change the location of the ellipse that is the egg because it is private: public class EggApplet extends Applet{ // Constants, variables, etc. private Ellipse2D.Double egg; MouseSpy listener = new MouseSpy(); addmouselistener(listener); // etc.. class MouseClickListener extends MouseAdapter { // MouseClickListener objects have not access // to the egg! 9

10 Source Code Solution A // Put the listener class inside the EggApplet class import java.applet.applet; import java.awt.graphics; import java.graphics2d; import java.awt.geom.ellipse2d; import java.awt.event.mouseevent; import java.awt.event. MouseAdapter; // create an EggApplet class public class EggApplet extends Applet{ // Constants, variables, etc. private Ellipse2D.Double egg; private static final double EDD_WIDTH = 15; private static final double EDD_HEIGHT = 25; // constructor public EggApplet() { egg = new Ellipse2D.Double(0,0,EGG_WIDTH, EGG_HEIGHT); MouseClickListener listener = new MouseClickListener(); addmouselistener(listener); public void paint(graphics g) { Graphics2D g2 = (Graphics2D)g; g2.draw(egg); // The lister class is declared inside the applet. private class MouseClickListener extends MouseAdapter { // only override one method public void mouseclicked(mouseevent event) { int mousex = event.getx(); int mousey = event.gety(); egg.setframe(mousex EGG_WIDTH/2, mousey EGG_HEIGHT/2, EGG_WIDTH, EGG_HEIGHT); repaint(); 10

11 Notes from the Applet The constructor of the applet creates an instance of the inner class. The inner class will remember the object in which it was constructed. MouseClickListener listener = new MouseClickListener(); The inner class has no variable named egg, so it looks in the outer class for the egg variable and finds it. Because the MouseClickListener object is an object of the inner class it can freely access the private variable egg. egg.setframe(mousex EGG_WIDTH/2, mousey EGG_HEIGHT/2, EGG_WIDTH, EGG_HEIGHT); setframe() is an ellipse method that updates the position and size of the ellipse. repaint() tells the Java Runtime to tell the Window manager to call the paint() method so that the ellipse can be redrawn in its new position. You could call the paint() method directly yourself since it is a public method of the applet, but this you should never do. Other activities are probably going on while you are running your applet. Let the Window Manager paint() the applet again when it is convenient. The repaint() method belongs to the applet class. It does not show up in the previous definition because we did not override it. Note: objects created from inner classes are like instance variables of the outer class. They can see and use all methods and variables of both themselves and the outer class. You will use inner classes most frequently for event listeners. 11

12 Frame Windows Let's create a windows application that is not an applet. Such an application does not run inside a browser such as Netscape, but deals with the Operating System through the Java Runtime. Here is the code that would create 2 simple windows: // filename: FrameTest1.java import javax.swing.jframe; public class FrameTest1 { public static void main(string [] args) { EmptyFrame frame1 = new EmptyFrame(); frame1.settitle("frame Test"); frame1.show(); EmptyFrame frame2 = new EmptyFrame(); frame2.settitle("second Frame"); frame2.show(); System.out.println("\n\nMain method is terminating, but Window remains."); // System.exit(0); // This is the simple window class class EmptyFrame extends JFrame { public EmptyFrame(){ // constructor final int DEFAULT_FRAME_WIDTH = 300; // pixels final int DEFAULT_FRAME_HEIGHT = 300; // pixels setsize(default_frame_width, DEFAULT_FRAME_HEIGHT); 12

13 Notes about FrameTest1.java You will notice that the main method ends but the two windows continue to exist. When any window is created it receives it's own thread. A thread is like a unit of execution in the operating system. You will also notice that the program does not stop running until I press CTRL-C. While the main() method thread has finished the thread that display the windows to you must be manually killed. You will notice that the window has a border and a title bar. All Java Frames have these two things, though this is not necessarily the case for other programming languages. The applet has a border but no title bar. (The title bar of the applet viewer is what you see when you use that program.) This program uses the javax.swing package. A few years ago you used components from the AWT package to create windows, but this created problems. The AWT used frames, buttons, and other components from the native platforms it ran on. The frames, buttons, entry fields, and other components that Microsoft, Apple, and Unix offered where similar to eachother in most respects, but just different enough from eachother to cause lots of headaches for programmers. 'Write once run everywhere' became 'write once, debug everywhere'. The javax (Java extensions) package literally paints every component that it offers from scratch. This makes it a bit slow but very consistent. 13

14 Killing your program The System.exit(0); call will terminate your program and the runtime, but when should you call this? frame.show(); System.exit(0); Putting this command at the end of the main method will cause the windows to show for a split second and then close as the runtime exits. The ideal solution is to only have the program terminate when both windows are closed. How do we accomplish this? Step 1: Implement the WindowListener interface Just as applets can receive event notifications, so can windows if they implement the WindowListener interface. The abstract methods of the above interface are given below: public interface WindowListener { void windowopened(windowevent e); void windowclosed(windowevent e); void windowactivated(windowevent e); void windowdeactivated(windowevent e); void windowiconified(windowevent e); void windowdeiconified(windowevent e); void windowclosing(windowevent e); Just as there is a MouseAdaptor class that implements the MouseListener methods for you, there is a WindowAdaptor class that does the same thing. 14

15 Closing the Program 1) Suppose we add a class variable to the EmptyFrame class that keeps track of how many windows are open at a given time: private static int window_count = 0; 2) We increment that variable in the constructor of the EmptyFrame class: window_count++; 3) Suppose we create an event handler that decrements the count and kills the program if the count reaches 0. We will make that class an inner class of the EmptyFrame class: 4) Notice that you need to create an event handler for each window that you open. 5) One problem of using adaptor classes is that minor typos can lead to strange problems. For example, if you type the windowclosing method as WindowClosing you will have created a new method that does not receive the window event notification. 15

16 FrameTest2.java import javax.swing.jframe; import java.awt.event.windowevent; import java.awt.event.windowadapter; public class FrameTest2 { public static void main(string [] args) { EmptyFrame frame1 = new EmptyFrame(); frame1.settitle("frame Test"); frame1.show(); EmptyFrame frame2 = new EmptyFrame(); frame2.settitle("second Frame"); frame2.show(); // This is the slightly modified simple window class class EmptyFrame extends JFrame { private static int window_count = 0; // Note 1 public EmptyFrame(){ // constructor final int DEFAULT_FRAME_WIDTH = 300; // pixels final int DEFAULT_FRAME_HEIGHT = 300; // pixels setsize(default_frame_width, DEFAULT_FRAME_HEIGHT); WindowCloser listener = new WindowCloser(); addwindowlistener(listener); // Note 4 System.out.println("Added Window Listener"); window_count++; // Note 2 System.out.println("New window #" + window_count); // this is the event handler private class WindowCloser extends WindowAdapter { public void windowclosing(windowevent e){ // Note 3, 5 window_count--; System.out.println("Window #" + window_count + " closed"); if (window_count < 1) { System.exit(0); 16

17 Adding Components to JFrames JFrame Components are more complex than applet frames. With applets you draw right onto the applet frame. JFrames are actually composed of several layers: Titlebar Menu bar (optional) JFrame Root Pane Holds the glass pane and the content pane together Layered Pane The Content Pane and the Menu bar are mounted on the Layered Pane. Glass Pane The primary purpose of the glass pane is capture mouse events. The glass pane is transparent. Content Pane This one holds the components that you will put on the window 17

18 Adding a Component to the Window To add a component to a window you need to create a panel and place it on the Content Pane. // filename FrameTest3 import javax.swing.jframe; import javax.swing.jpanel; import java.awt.component; import java.awt.container; import java.awt.graphics; import java.awt.graphics2d; public class FrameTest3 { public static void main(string [] args) { MyFrame frame = new MyFrame(); frame.settitle("one Centered Panel"); frame.show(); class MyPanel extends JPanel { // This is the panel that we will put on the window public void paintcomponent(graphics g) { super.paintcomponent(g); Graphics2D g2 = (Graphics2D)g; g2.drawstring("hi there!", 50, 50); class MyFrame extends JFrame { public MyFrame() { // constructor MyPanel panel = new MyPanel(); Container contentpane = getcontentpane(); contentpane.add(panel, "Center"); final int DEFAULT_FRAME_WIDTH = 300; // pixels final int DEFAULT_FRAME_HEIGHT = 300; // pixels setsize(default_frame_width, DEFAULT_FRAME_HEIGHT); 18

19 Notes: FrameTest3.java Notice that while the applet has a paint method, the JPanel has a paintcomponent method. public void paintcomponent(graphics g) { super.paintcomponent(g); Also notice the call to the superclass method: paintcomponent( ). Every javax.swing component inherits this method and should call the superclass method. The superclass paintcomponent method will erase the previous contents of the panel, insure that the borders of the panel are drawn and the attributes of the graphics object g are set correctly. Panel Positioning: contentpane.add(panel, "Center"); Notice that a panel can only be positioning loosely on the Content Pane. The only options available are North, Center, South, East and West. (see page 416) 19

20 Reading in Text Input The final example of the chapter deals with reading in text from a JTextField control. These are very common and worth considering in some detail. Notes: The program has the typical JFrame component. The JFrame component has a private object instance: that of a JTextField. import javax.swing.jframe; import javax.swing.jtextfield; class MyFrame extends JFrame { // various declarations private JTextField textfield; // etc.. This text field is added to the window (MyFrame) at the bottom of the window: Container contentpane = getcontentpane(); contentpane.add(textfield, "South"); 20

21 Action Events Mouse events are more complex than the events that can occur in a text box, particularly in Java. While some languages allow you receive an event for every time the user presses a key while in the text box, the JTextField component only generates an event when the returns presses ENTER. This results in an Action event. To handle this event you will need to implement the ActionListener interface. This interface only has a single method: public interface ActionListener { public void actionperformed(actionevent event); The ActionEvent object contains various bits of information, such as which component generated the event, and what kind of event occured. We will look at this class in more detail next week, however; for now we know that we only have the JTextField that will be generating events. Here is the class that implements the interface. Notice the gettext() and the settext() methods that are part of the JTextField class... private class TextFieldListener implements ActionListener { public void actionperformed(actionevent event) { String input = textfield.gettext(); // do some stuff textfield.settext(""); 21

22 Implementation Let's walk through the code. This program allows you to enter data (an integer) into a textbox, then paints that many eggs (ellipses) at random locations in the window. // filename: Eggs.java /* Note: you need a lot of classes, so the import section is long. This is typical of modern software programs: no one person writes the program, but rather teams of people do. Even this simple program requires the work of the developers at Sun. */ import java.awt.container; import java.awt.graphics; import java.awt.graphics2d; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.awt.geom.ellipse2d; import java.util.random; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.jtextfield; /* Question 1: do you understand what role each of these classes will play? It is important to understand that each of the above classes represents an Entity. You must accept the notion that each of the above items has an individual nature. Each has attributes and behaviour (variables and methods) associated with it that you do not know about. */ 22

23 /* Notice how simple the Eggs class is. All it does is provide a place for the program to start, creates an EggFrame object, sets an attribute, and displays it to the user. Then the main() method ends. The EggFrame object does all the rest of the work itself. It truly acts as an independent entity with a life of its own. This is quite a departure from the practice of procedural programming where the main method is the source of most every command and action. */ public class Eggs { public static void main(string[] args) { EggFrame frame = new EggFrame(); frame.settitle("enter a number of eggs"); frame.show(); // end of Eggs class /* Here is the EggFrame class. This class is used to create the window object that will be displayed. This class contains classes of its own. An EggFrame object will contain other objects. An EggFrame object will handle it's own events. */ class EggFrame extends JFrame { // This frame class will contain a text field object mounted on // a panel object. private JTextField textfield; private EggPanel panel; 23

24 /* Event Handler class Notice how this class has one purpose only: it kills (exits, closes, destroys, etc.) this program when it receives the windowclosing() event. (How does it receive this event?) This is a very simple, inner class that belongs to the EggFrame class. It is used by the EggFrame class to close the program when the EggFrame window is closed by the user. */ private class WindowCloser extends WindowAdapter { public void windowclosing(windowevent event){ System.exit(0); // default constructor public EggFrame() { final int DEFAULT_FRAME_WIDTH = 300; final int DEFAULT_FRAME_HEIGHT = 300; /* NOTE: you always find these specifications laid out as constants. Magic Numbers are the kiss of death in the real world of programming. */ // This method is inherited. setsize(default_frame_width, DEFAULT_FRAME_HEIGHT); //WindowCloser closer = new WindowCloser(); //addwindowlistener(closer); addwindowlistener(new WindowCloser()); /* Notice the above method call. The statement new WindowCloser() returns a reference to a object that implements the WindowListener interface. You pass this reference to the addwindowlistener method. Notice that an an un-named object now exists as our Window Event handler, but the handler is simple so we don't care to keep track of it. */ panel = new EggPanel(); contentpane.add(panel, "Center"); textfield = new JTextField(); textfield.addactionlistener(new TextFieldListener()); contentpane.add(textfield,"south"); 24

25 /* Text Field event handler: another inner class We will use this class to handle events from the the text field. Actually, we could use this class for any text field. We know that an event occurs when the user enters text and presses ENTER. */ private class TextFieldListener implements ActionListener { // How does an ActionListener differ from a MouseListener? public void actionperformed(actionevent event) { String user_input = textfield.gettext(); int number = Integer.parseInt(user_input); // could an Exception be thrown? // If so, why doesn't the compiler complain? panel.seteggcount(number); textfield.settext(""); // where did this method come from? What does it do? // Why can the textfield be referenced here? 25

26 /* Here is the class that we draw eggs (Ellipses) on. */ class EggPanel extends JPanel { private int eggcount = 0; private static final double EGG_WIDTH = 30; private static final double EGG_HEIGHT = 50; // What is gained here in using constants? public void paintcomponent(graphics g) { super.paintcomponent(g); // why call the superclass' method? Graphics2D g2 = (Graphics2D)g; // what is happening here? Why do it? Random generator = new Random(); for (int ii = 0; ii < eggcount; ii++) { double x = getwidth() * generator.nextdouble(); double y = getheight() * generator.nextdouble(); Ellipse2D.Double egg = new Ellipse2D.Double(x,y, EGG_WIDTH, EGG_HEIGHT); g2.draw(egg); /* This method provides a way for the private variable eggcount to be set. */ public void seteggcount(int count) { eggcount = count; repaint(); // why not call paintcomponent directly? // end EggPanel class // end EggFrame class Note: this is a long, gritty program if you are new to the world of UI and components. I recommend that you type it in and compile it yourself. 26

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

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by

More information

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

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example

More information

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

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing. COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization

More information

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

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 123 Computer Creativity Graphics and Events Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Draw shapes, text in various fonts, and colors. 2) Build

More information

Chapter 1 GUI Applications

Chapter 1 GUI Applications Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations

More information

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners GUI (Graphic User Interface) Programming Part 2 (Chapter 8) Chapter Goals To understand the Java event model To install action and mouse event listeners To accept input from buttons, text fields, and the

More information

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

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic

More information

G51PRG: Introduction to Programming Second semester Applets and graphics

G51PRG: Introduction to Programming Second semester Applets and graphics G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

User interfaces and Swing

User interfaces and Swing User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends

More information

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Graphical Interfaces

Graphical Interfaces Weeks 11&12 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The

More information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

BM214E Object Oriented Programming Lecture 13

BM214E Object Oriented Programming Lecture 13 BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place

More information

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

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/

More information

The AWT Event Model 9

The AWT Event Model 9 The AWT Event Model 9 Course Map This module covers the event-based GUI user input mechanism. Getting Started The Java Programming Language Basics Identifiers, Keywords, and Types Expressions and Flow

More information

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology: Inheritance 1 Inheritance One class inherits from another if it describes a specialized subset of objects Terminology: the class that inherits is called a child class or subclass the class that is inherited

More information

Programming Mobile Devices J2SE GUI

Programming Mobile Devices J2SE GUI Programming Mobile Devices J2SE GUI University of Innsbruck WS 2009/2010 thomas.strang@sti2.at Graphical User Interface (GUI) Why is there more than one Java GUI toolkit? AWT write once, test everywhere

More information

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN CSSE 220 Event Based Programming Check out EventBasedProgramming from SVN Interfaces are contracts Interfaces - Review Any class that implements an interface MUST provide an implementation for all methods

More information

Swing from A to Z Using Focus in Swing, Part 2. Preface

Swing from A to Z Using Focus in Swing, Part 2. Preface Swing from A to Z Using Focus in Swing, Part 2 By Richard G. Baldwin Java Programming, Lecture Notes # 1042 November 27, 2000 Preface Introduction Sample Program Interesting Code Fragments Summary What's

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals

More information

Graphical Interfaces

Graphical Interfaces Weeks 9&11 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The

More information

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } } 9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use

More information

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

11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events Objectives Event Handling Animation Discussion of Roulette Assignment How easy/difficult to refactor for extensibility? Was it easier to add to your refactored code? Ø What would your refactored classes

More information

Swing from A to Z Some Simple Components. Preface

Swing from A to Z Some Simple Components. Preface By Richard G. Baldwin baldwin.richard@iname.com Java Programming, Lecture Notes # 1005 July 31, 2000 Swing from A to Z Some Simple Components Preface Introduction Sample Program Interesting Code Fragments

More information

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Graphics programming COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson) Overview Aims To provide an overview of Swing and the AWT To show how to build

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

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

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how

More information

Programming Language Concepts: Lecture 8

Programming Language Concepts: Lecture 8 Programming Language Concepts: Lecture 8 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 8, 11 February 2009 GUIs and event

More information

Advanced Java Programming (17625) Event Handling. 20 Marks

Advanced Java Programming (17625) Event Handling. 20 Marks Advanced Java Programming (17625) Event Handling 20 Marks Specific Objectives To write event driven programs using the delegation event model. To write programs using adapter classes & the inner classes.

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

Programming Languages and Techniques (CIS120e)

Programming Languages and Techniques (CIS120e) Programming Languages and Techniques (CIS120e) Lecture 29 Nov. 19, 2010 Swing I Event- driven programming Passive: ApplicaHon waits for an event to happen in the environment When an event occurs, the applicahon

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Lecture 5: Java Graphics

Lecture 5: Java Graphics Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,

More information

Class 16: The Swing Event Model

Class 16: The Swing Event Model Introduction to Computation and Problem Solving Class 16: The Swing Event Model Prof. Steven R. Lerman and Dr. V. Judson Harward 1 The Java Event Model Up until now, we have focused on GUI's to present

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

Handling Mouse and Keyboard Events

Handling Mouse and Keyboard Events Handling Mouse and Keyboard Events 605.481 1 Java Event Delegation Model EventListener handleevent(eventobject handleevent(eventobject e); e); EventListenerObject source.addlistener(this);

More information

GUI Event Handlers (Part I)

GUI Event Handlers (Part I) GUI Event Handlers (Part I) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda General event

More information

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

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

CS 2113 Software Engineering

CS 2113 Software Engineering CS 2113 Software Engineering Java 5 - GUIs Import the code to intellij https://github.com/cs2113f18/template-j-5.git Professor Tim Wood - The George Washington University Class Hierarchies Abstract Classes

More information

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge

More information

GUI Programming: Swing and Event Handling

GUI Programming: Swing and Event Handling GUI Programming: Swing and Event Handling Sara Sprenkle 1 Announcements No class next Tuesday My Fourth of July present to you: No quiz! Assignment 3 due today Review Collections: List, Set, Map Inner

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

(Incomplete) History of GUIs

(Incomplete) History of GUIs CMSC 433 Programming Language Technologies and Paradigms Spring 2004 Graphical User Interfaces April 20, 2004 (Incomplete) History of GUIs 1973: Xerox Alto 3-button mouse, bit-mapped display, windows 1981:

More information

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn Java & Graphical User Interface II Wang Yang wyang AT njnet.edu.cn Outline Review of GUI (first part) What is Event Basic Elements of Event Programming Secret Weapon - Inner Class Full version of Event

More information

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

กล ม API ท ใช. Programming Graphical User Interface (GUI) Containers and Components 22/05/60 กล ม API ท ใช Programming Graphical User Interface (GUI) AWT (Abstract Windowing Toolkit) และ Swing. AWT ม ต งต งแต JDK 1.0. ส วนมากจะเล กใช และแทนท โดยr Swing components. Swing API ปร บปร งความสามารถเพ

More information

Lecture 19 GUI Events

Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous inner classes Proper interaction

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for

More information

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

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in

More information

Windows and Events. created originally by Brian Bailey

Windows and Events. created originally by Brian Bailey Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating

More information

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

CSE 331 Software Design and Implementation. Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 7 due Thursday 8/9 Homework 8 due Thursday 8/9 HW8 has a regression testing

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Spring 2017 GUI Event-Driven Programming 1 The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous

More information

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

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT CSE 331 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/

More information

CS 11 java track: lecture 3

CS 11 java track: lecture 3 CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

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

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC). The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,

More information

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

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything. Java - Applications C&G Criteria: 5.3.2, 5.5.2, 5.5.3 Java applets require a web browser to run independently of the Java IDE. The Dos based console applications will run outside the IDE but have no access

More information

Object-oriented programming in Java (2)

Object-oriented programming in Java (2) Programming Languages Week 13 Object-oriented programming in Java (2) College of Information Science and Engineering Ritsumeikan University plan last week intro to Java advantages and disadvantages language

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

COMPSCI 230. Software Design and Construction. Swing

COMPSCI 230. Software Design and Construction. Swing COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming Objectives: Last revised 1/15/10 1. To introduce the notion of a component and some basic Swing components (JLabel, JTextField, JTextArea,

More information

Graphical User Interfaces (GUIs)

Graphical User Interfaces (GUIs) CMSC 132: Object-Oriented Programming II Graphical User Interfaces (GUIs) Department of Computer Science University of Maryland, College Park Model-View-Controller (MVC) Model for GUI programming (Xerox

More information

GUI in Java TalentHome Solutions

GUI in Java TalentHome Solutions GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 32 April 9, 2018 Swing I: Drawing and Event Handling Chapter 29 HW8: Spellchecker Available on the web site Due: Tuesday! Announcements Parsing, working

More information

CS11 Java. Fall Lecture 3

CS11 Java. Fall Lecture 3 CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of

More information

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

Part 3: Graphical User Interface (GUI) & Java Applets 1,QWURGXFWLRQWR-DYD3URJUDPPLQJ (( Part 3: Graphical User Interface (GUI) & Java Applets EE905-GUI 7RSLFV Creating a Window Panels Event Handling Swing GUI Components ƒ Layout Management ƒ Text Field ƒ

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

UCLA PIC 20A Java Programming

UCLA PIC 20A Java Programming UCLA PIC 20A Java Programming Instructor: Ivo Dinov, Asst. Prof. In Statistics, Neurology and Program in Computing Teaching Assistant: Yon Seo Kim, PIC University of California, Los Angeles, Summer 2002

More information

Graphical User Interfaces. Comp 152

Graphical User Interfaces. Comp 152 Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from

More information

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping.

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping. HW#1: Pencil Me In Status!? CS193J: Programming in Java Summer Quarter 2003 Lecture 6 Inner Classes, Listeners, Repaint Manu Kumar sneaker@stanford.edu How was Homework #1? Comments please? SITN students

More information

AP CS Unit 12: Drawing and Mouse Events

AP CS Unit 12: Drawing and Mouse Events AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 35 April 15, 2013 Swing III: OO Design, Mouse InteracGon Announcements HW10: Game Project is out, due Tuesday, April 23 rd at midnight If you want

More information

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms. Java GUI Windows Events Drawing 1 Java GUI Toolkits Toolkit AWT Description Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

More information

CS11 Java. Fall Lecture 4

CS11 Java. Fall Lecture 4 CS11 Java Fall 2006-2007 Lecture 4 Today s Topics Interfaces The Swing API Event Handlers Inner Classes Arrays Java Interfaces Classes can only have one parent class No multiple inheritance in Java! By

More information

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

(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI 51 6!! GUI(Graphical User Interface) java.awt javax.swing (component) GUI... (container) (listener)... MouseListener, ActionLister (adapter)... MouseAdapter, ActionAdapter 6.1 GUI(Graphics User Interface

More information

MIT AITI Swing Event Model Lecture 17

MIT AITI Swing Event Model Lecture 17 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 user. But how do GUIs interact with users? How do applications

More information

Interacción con GUIs

Interacción con GUIs 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

More information

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill dewan@cs.unc.edu Code available at: https://github.com/pdewan/colabteaching PRE-REQUISITES Model-

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

Java Interfaces Part 1 - Events Version 1.1

Java Interfaces Part 1 - Events Version 1.1 Java Interfaces Part 1 - Events Version 1.1 By Dr. Nicholas Duchon July 22, 2007 Page 1 Overview Philosophy Large Scale Java Language Structures Abstract classes Declarations Extending a abstract classes

More information

Graphical User Interface

Graphical User Interface Lecture 10 Graphical User Interface An introduction Sahand Sadjadee sahand.sadjadee@liu.se Programming Fundamentals 725G61 http://www.ida.liu.se/~725g61/ Department of Computer and Information Science

More information

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development CSCI 053 Introduction to Software Development Rhys Price Jones Week 5 Java is like Alice not based on Joel Adams you may want to take notes Objectives Learn to use the Eclipse IDE Integrated Development

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Using the API: Introductory Graphics Java Programming 1 Lesson 8

Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first

More information

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) ) Course Evaluations Please do these. -Fast to do -Used to

More information

Final Examination Semester 2 / Year 2012

Final Examination Semester 2 / Year 2012 Final Examination Semester 2 / Year 2012 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates:

More information

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

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT INSTITUTIONEN FÖR Tool Kits, Swing SMD158 Interactive Systems Spring 2005 Jan-28-05 2002-2005 by David A. Carr 1 L Overview Tool kits in the abstract An overview of Swing/AWT Jan-28-05 2002-2005 by David

More information

UI Software Organization

UI Software Organization UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app

More information

Cheng, CSE870. More Frameworks. Overview. Recap on OOP. Acknowledgements:

Cheng, CSE870. More Frameworks. Overview. Recap on OOP. Acknowledgements: More Frameworks Acknowledgements: K. Stirewalt. Johnson, B. Foote Johnson, Fayad, Schmidt Overview eview of object-oriented programming (OOP) principles. Intro to OO frameworks: o Key characteristics.

More information