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

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

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

Object-oriented programming in Java (2)

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

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!

CS Programming Language - JAVA. Fall 2004 Oct.13rd

Programmierpraktikum

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

Graphic User Interfaces. - GUI concepts - Swing - AWT

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

2D Graphics. Shape Models, Drawing, Selection. CS d Graphics 1

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

CSE 331 Software Design & Implementation

Graphic Interface Programming II Using Swing and OOP more advanced issues. Uppsala universitet

Lecture 5: Java Graphics

Final Examination Semester 2 / Year 2012

Assignment 2. Application Development

Lecture 18 Java Graphics and GUIs

Graphical User Interface (GUI)

Graphical User Interfaces (GUIs)

Lecture 3: Java Graphics & Events

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

IT101. Graphical User Interface

G51PRG: Introduction to Programming Second semester Applets and graphics

Graphical User Interface (GUI)

Programming Languages and Techniques (CIS120)

2D Graphics. Shape Models, Drawing, Selection. CS d Graphics 1

Announcements. Introduction. Lecture 18 Java Graphics and GUIs. Announcements. CSE 331 Software Design and Implementation

Final Examination Semester 2 / Year 2011

Introduction to the JAVA UI classes Advanced HCI IAT351

CSE wi Final Exam 3/12/18 Sample Solution

Programming Languages and Techniques (CIS120)

CSE 331 Software Design & Implementation

CSE wi Final Exam 3/12/18. Name UW ID#

CS 251 Intermediate Programming GUIs: Components and Layout

CompSci 230 S Programming Techniques. Basic GUI Components

Windows and Events. created originally by Brian Bailey

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

Final Examination Semester 2 / Year 2010

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

Software Construction

User interfaces and Swing

First Name: AITI 2004: Exam 2 July 19, 2004

Graphics and Painting

Object Orientated Programming in Java. Benjamin Kenwright

This page intentionally left blank

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

First Name: AITI 2004: Exam 2 July 19, 2004

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

Shared Collection of Java Course Materials: New Topics Covered. Agenda

H212 Introduction to Software Systems Honors

Window Interfaces Using Swing Objects

Java Swing Introduction

Introduction to Computer Science I

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2

MODEL UPDATES MANIPULATES USER

TWO-DIMENSIONAL FIGURES

CS193k, Stanford Handout #3. Swing 1

Here is a list of a few of the components located in the AWT and Swing packages:

UI Software Organization

Chapter 13 Lab Advanced GUI Applications

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 :) )

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Building a Java First-Person Shooter

CIS 162 Project 1 Business Card Section 04 (Kurmas)

Widgets. Widgets Widget Toolkits. User Interface Widget

Question 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.

Lecture 7 A First Graphic Program And Data Structures & Drawing

Lecture 9. Lecture

EPITA Première Année Cycle Ingénieur. Atelier Java - J5

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

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

Chapter 2 Using Objects. Types. Number Literals. A type defines a set of values and the operations that can be carried out on the values Examples:

Window Interfaces Using Swing Objects

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

Dr. Hikmat A. M. AbdelJaber

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

Graphic Interface Programming II Events and Threads. Uppsala universitet

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

Programming graphics

Swing: Building GUIs in Java

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Graphical interfaces & event-driven programming

Graphical User Interfaces 2

(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci

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

Swing: Building GUIs in Java

Java Coordinate System

Java: Graphical User Interfaces (GUI)

CS 11 java track: lecture 3

Give one example where you might wish to use a three dimensional array

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Sri Vidya College of Engineering & Technology

PIC 20A GUI with swing

PROGRAMMING LANGUAGE 2

Transcription:

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 with native platform GUI toolkit Lowest-common denominator for all platforms Platform dependent bugs Swing GUI widgets painted onto blank windows Only native support was that required to display window Look-and-feel adaptable to Windows, Motif, Metal, GTK (new) More consistent behavior across platforms 2

Model-View-Controller Model: The data that drives what is to be shown (application semantics) View: How the data is shown to the user (output) Controller: Mechanism that reacts to the user (user input) View Model (data) Controller Swing Container, Controls 3

GUI in Java Often easier to think in terms of containers and controls Container: An area of the display that can hold visual controls and other containers Controls: A visual display item that can be manipulated by the user directly (buttons, fields, etc.) controls containers Enter Name: text field 4

Containers Basic window container is a JFrame Has a title bar with icon, minimize, maximize, close buttons Is automatically given an additional container called a content pane Title Here JFrame JPanel (content pane) 5

Frame import javax.swing.*; public class SimpleFrameTest public static void main(string[] args) SimpleFrame frame = new SimpleFrame(); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.show(); class SimpleFrame extends JFrame public SimpleFrame() setsize(width, HEIGHT); public static final int WIDTH = 300; public static final int HEIGHT = 200; 6

Containers Basic workhorse container is the JPanel Used to group controls, other containers Can have its own border Inherits from class Jcomponent To draw on a panel Define class that extends JPanel Override the paintcomponent method Title Here Other JPanels JFrame JPanel (content pane) 7

Containers class NotHelloWorldPanel extends JPanel public void paintcomponent(graphics g) super.paintcomponent(g); g.drawstring("not a Hello, World program", MESSAGE_X, MESSAGE_Y); public static final int MESSAGE_X = 75; public static final int MESSAGE_Y = 100; 8

2D Shapes Requires Graphics2D class Subclass of Graphics Stores context information for graphics rendering Current color, brush width, etc. Use draw method to render a shape public void paintcomponent(graphics g) super.paintcomponent(g); Graphics2D g2 = (Graphics2D)g;... Rectangle2D rect = new Rectangle2D.Double(leftX, topy, width, height); g2.draw(rect); Basic shapes Line2D, Rectangle2D, Ellipse2D Outline or filled Core Java Examples 9

Homework Look in L:\eng students\csce093\javastuff\v1ch7 and run the examples in there Look in L:\eng students\csce093\course Notes\Stacks and Parsing Arithmetic Expressions.pdf Write a program that uses a stack. Push some numbers on to the stack, pop them off, clear the stack, etc. Write a program that takes the first argument static public void main(string args[]) Evaluator e = new Evaluator(); System.out.println(e.eval(args[0])); So Java eval 6 * 7 + 4 will yield 46. STEAL CODE FROM the Stacks pdf... Cooperate to Graduate Your code better be your own tho, or stolen from an outside source 10