Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Your First Java Program: HelloWorld.java
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Event-Driven Programming Event:  A signal to the program that something has happened.  It can be triggered either by external user actions, such as mouse.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Unit 12 Object-oriented programming: Event-driven programming for GUI Jin Sa.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Graphical User Interfaces
Object-Oriented Analysis and Design
Chapter 7 Improving the User Interface
GUI and Event-Driven Programming Part 2. Event Handling An action involving a GUI object, such as clicking a button, is called an event. The mechanism.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Io package as Java’s basic I/O system continue’d.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
1 Event Driven Programming wirh Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
MVC CompSci 230 S Software Construction. MVC Architecture  A typical application includes software to  maintain application data,  document text.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
CSE 501N Fall ‘09 20: Event Handling and Inner Classes 17 November 2009 Nick Leidenfrost.
Event Handling Mohanraj S AP / IT Angel College of Engg & Tech.,
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
COMP 321 Week 2. Outline Event-Driven Programming Events, Event Sources, Event Listeners Button and Timer Events Mouse Events, Adapters.
An Introduction to Programming and Object Oriented Design using Java 3 rd Edition. Dec 2007 Jaime Niño Frederick Hosch Chapter 18 Integrating user interface.
Mini University July, 2005 A Little Taste of Java (but don’t tell your folks) (they might think there’s caffeine involved)
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Anonymous Classes An anonymous class is a local class that does not have a name. An anonymous class allows an object to be created using an expression.
Object Oriented Programming.  Interface  Event Handling.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7-2 ( Book Chapter 14) GUI and Event-Driven Programming.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Graphical User Interfaces A Graphical User Interface (GUI) in Java is created with at least three kinds of objects: –components, events, and listeners.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Lesson 28: More on the GUI button, frame and actions.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
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.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
Lecture 15 Basic GUI programming
Computer Programming Your First Java Program: HelloWorld.java.
CSC 205 Programming II Lecture 5 AWT - I.
Events and Event Handling
CompSci 230 S Programming Techniques
GUIs Model/View/Controller Pattern Using BreezySwing
Processing Timer Events
Ellen Walker Hiram College
Event Driven Programming
Event loops 17-Jan-19.
Constructors, GUI’s(Using Swing) and ActionListner
Tonga Institute of Higher Education
Presentation transcript:

Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }

Java -compile and run test Type in the text of the program and save as a java program. E.g., HelloWorld.java Compile program: –javac HelloWorld.java Run the program: –java HelloWorld compile and run ButtonTest.java –

The Model-View-Controller (MVC) is a commonly used and powerful architecture for GUIs The MVC paradigm is a way of breaking an application into input, processing and output. Input --> Processing --> Output Controller --> Model --> View

In the case of word processors, the Controller collects keystrokes from the keyboard and delivers them to the Model which notifies the View that the data has changed so that the updated data can be displayed.

Model View Controller Model- the data View - the GUI (output) Controller - user input (mouse click)

MVC  Model : The core of the application. This maintains the state and data that the application represents. When significant changes occur in the model, it updates all of its views  Controller : The user interface presented to the user to manipulate the application.  View : The user interface which displays information about the model to the user. Any object that needs information about the model needs to be a registered view with the model.

AWT/Swing basics Graphical objects (Component objects) are contained in Container objects. Container (also a component) objects, may be nested. You can construct a GUI with these steps: –Create a GUI component: JButton okButton = new JButton(“OK”); –Add the component to a container: add(okButton);

Event Handling Respond to events generated by the component: –you must attach an event listener to the component: okButton.addActionListener(this); –An event listener is an instance of a class that implements the event listener for the appropriate event type. (other types: window event)

The listener: public void actionPerformed(ActionEvent event) { if (event.getSource() == okButton) okButton.getToolkit().beep; }

homework Write a Java GUI program 1) that accepts input into a text area 2) contains a button labeled “Read Text” 3) outputs the typed text when the button is pressed.

Project 1 dates Sept. 16 (break into groups) –Pick an User Interface to design –Begin designing interface on paper Sept. 25 (next Wednesday) –Present design to class –Collect usability attributes. (I’ll pass out a question and answer sheet.) –The group will then re-design the interface based on what the question and answer sheets indicates. Oct. 2 (the following Wednesday) –Present your findings based the collected data from the question and answer sheets –Re-present the new enhanced design.