News and info. Array. Feedback. Lab 4 is due this week. It should be easy to change the size of the game grid.

Similar documents
Lecture 11. Lecture

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

CS 251 Intermediate Programming GUIs: Components and Layout

Introduction to the JAVA UI classes Advanced HCI IAT351

Layout. Dynamic layout, Swing and general layout strategies

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

Containers and Components

No SVN checkout today. Object-Oriented Design

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

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

CSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

CSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Graphical User Interface (GUI)

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

What is Widget Layout? COSC 3461 User Interfaces. Hierarchical Widget Layout. Resizing a Window. Module 5 Laying Out Components

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

INSTITUTE OF AERONAUTICAL ENGINEERING

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

Lecture 9. Lecture

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

Contents Chapter 1 Introduction to Programming and the Java Language

Java Programming Lecture 6

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

Window Interfaces Using Swing Objects

CS11 Java. Fall Lecture 4

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

CSE 1325 Project Description

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

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

Design patterns for graphical user interface applications

Laying Out Components. What is Widget Layout?

An array is a type of variable that is able to hold more than one piece of information under a single variable name.

Java IDE Programming-I

Graphical User Interface (GUI)

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5.

Basicsof. JavaGUI and SWING

Dr. Hikmat A. M. AbdelJaber

Part I: Learn Common Graphics Components

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

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

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

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

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

Window Interfaces Using Swing Objects

Unit 6: Graphical User Interface

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

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Swing. By Iqtidar Ali

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

Object Oriented Design & Patterns. Part 1

Lecture 5: Java Graphics

Systems Programming Graphical User Interfaces

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

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

ITEC 120 4/14/11. Review. Need. Objectives. GUI basics JFrame JPanel JLabel, JButton, JTextField Layout managers. Lecture 38 GUI Interactivity

DM503 Programming B. Peter Schneider-Kamp.

Lab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!

Summary Chapter 25 GUI Components: Part 2

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

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

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); }

Programming graphics

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Graphical User Interfaces. Comp 152

Swing from A to Z Some Simple Components. Preface

Programming Languages and Techniques (CIS120)

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

YouTube Break.

5. In JAVA, is exception handling implicit or explicit or both. Explain with the help of example java programs. [16]

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Java. GUI building with the AWT

Human-Computer Interaction IS4300

Global Gomoku Lab 4 in D0010E

China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert

Programming Languages and Techniques (CIS120)

Top-Level Containers

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!

PIC 20A GUI with swing

Window Interfaces Using Swing. Chapter 12

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

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

AP CS Unit 11: Graphics and Events

CS 180 Final Exam Review 12/(11, 12)/08

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

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

JAVA. A. Zakiuddin Ahmed. M.Sc.,M.Phil M.S.(Edn), PGDCSM, Professor in Computer Science, P. Rizwan Ahmed. MCA., M.Sc.,M.A., M.Phil.

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

Transcription:

Calculation Applet! Arrays! Sorting! Java Examples! D0010E! Lecture 11! The GUI Containment Hierarchy! Mergesort! News and info Lab 4 is due this week. It should be easy to change the size of the game grid. Use (public final) constants in your code. You can assume that both programs playing have the same grid size. 2 Feedback Anonymous classes..? Immediate creation of a tailor-made dynamic object based on an existing class or interface. Example in SpringLayoutExample from Lecture 9. Based on the interface ActionListener. Eck and Pilay, p. 96 (Section 5.2.1 in Part 2 of the course compendium). Another example today. Array Declaration: <Type> [] <variable>; Example: Room[] rooms;! Creation: <variable> = new <Type> [ <size> ]! Example:"!!rooms = new Room[10]; Use: <variable> (rooms) <variable> [ <index> ]!(rooms[3])! <index> must be in the range [0..<size>-1]. <variable>. length (rooms.length) 3 4

Multi-dimensional arrays "Arrays of arrays". <Type> [] [] [] <variable>; The number of pairs of brackets is the dimension. Example: ChessPiece[][][] chessboard3d;! A d-dimensional array = a 1-dimensional containing (d-1)-dimensional arrays. Ragged arrays. All arrays in some dimension need not be of equal length. It is possible to create a multi-dimensional array in steps. Fig 4.19 d-dimensional arrays 3 declarations on page 153 5 6 Fig 4.23 GUI Components Ragged arrays Java s library contains classes with readymade, commonly used graphical components. JPanel JButton JTextField JLabel, etc They all have JComponent as super class. These are to a large extent configurable. They support quite a few methods for this. As shown at the last lecture, they can also be extended (specialized via inheritance) like classes in general. 7 8

GUI Containers A GUI container can hold components and (other) containers. The various containers and their contents define a containment hierarchy. Highest up in the containment hierarchy is always a top-level container. JFrame, JApplet, or JDialog. JPanel is a both a container and a component. Layouts The relative sizes and positions of GUI components and containers with respect to each other is governed by LayoutManagers. BorderLayout, GridLayout, GridBagLayout, SpringLayout etc. Each layout-manager positions and re-sizes components according to a strategy of its own. Each container is assigned a default layoutmanager when created. setlayout( ) can be used to change the layoutmanager of a container. Every container in the containment hierarchy has a layout-manager of its own working within the premises of its parent layoutmanager. 9 10 Containment Hierarchy CalculatorApplet 2 containers! 4 components! A layout-manager! per container! 11 12

CalculatorApplet Eclipse/handout BinaryOperatorButton and" Concrete Subclasses Separate paper 13 14 UML for Binary Operator Buttons MyCalculatorApplet1 Separate slide 15 16

MyCalculatorApplet2, Power, and a new Plus (MyPlus) Separate slide MyCalculatorApplet3 Separate slide 17 18 Sorting Comparable The problem of sorting is fundamental in computing as (very) large parts of what computers do today is to "sort". By sorting is meant the re-arrangement of the elements in a sequence so they occur in order. Sorting 3,5,1,2,4 results in 1,2,3,4,5. All sequences containing comparable elements can be sorted. In Java, a sequence can be an array or vector, for example. 19 20

Example: Mergesort Mergesort is a algorithm to sort based on divide and conquer. Sorts lists of comparable items. Used (invented?) by John von Neumann to program ENIAC in 1945. Informally, Mergesort works as follows: 1. Divide the unsorted list into two sublists of about half the size. 2. Sort each of the two sublists. Use Mergesort twice here. 3. Merge the two sorted sublists back into one sorted list, and we are done. 21 22 mergesort in Eclipse 23