GUI AND GRAPHICS.

Slides:



Advertisements
Similar presentations
Graphical User Interfaces
Advertisements

Lecture 3 A First Graphic Program. Features of a simple graphic program.
Web Design & Development Lecture 19. Java Graphics 2.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Computer Science 209 Graphics and GUIs. Working with Color The class java.awt.Color includes constants for typical color values and also supports the.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Applets & Applications CSC 171 FALL 2001 LECTURE 15.
Carnegie Mellon University, MISM1 Java GUI programming and Java Threads GUI example taken from “Computing Concepts with Java 2” by Cay Horstmann Thread.
Object Oriented Programming Java 1 GUI example taken from “Computing Concepts with Java 2” by Cay Horstmann GUI Programming.
CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,
Lecture 18 Review the difference between abstract classes and interfaces The Cloneable interface Shallow and deep copies The ActionListener interface,
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Unit 11 Object-oriented programming: Graphical user interface Jin Sa.
Java Concepts Chapter 2 – Graphical Applications Mr. Smith AP Computer Science A.
Web Design & Development Lecture 18. Java Graphics.
Draw Shapes Introduction to simple graphics. What is a Component? A class that resides in the java.awt package Examples include: –Button, java.awt.Button.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Screen Saver Application.
JAPPLET.
CSE 219 Computer Science III Graphical User Interface.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
tiled Map Case Study: Rendering with JPanel © Allan C. Milne v
J McQuillan SE204: 2004/2005: Lecture 4slide 1 The Graphics Class Used when we need to draw to the screen Two graphics classes –Graphics –Graphics2D.
© A+ Computer Science - Chicken yeller = new Chicken();
Previous programs used a JLabel for OUTPUT. Another Swing component that can be used for both user input and output is the JTextfield. Suppose we want.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. In order to display a drawing in a frame, define a class that extends.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Java Graphics Stuart Hansen 11/6/03. What’s Wrong with OpenGL Graphics – not GUI –No real support of text boxes, buttons, etc. Procedural - not OOP –No.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Java Dynamic Graphics.
Clicker quick questions 10/17/13 CSE 1102 Fall 2013.
Review_6 AWT, Swing, ActionListener, and Graphics.
Java Swing One of the most important features of Java is its ability to draw graphics.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Java Graphics Chris North cs3724: HCI. Presentations peter hou Vote: UI Hall of Fame/Shame?
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Graphical User Interfaces
Graphical User Interfaces
Java Graphics.
Lecture 10 Graphics D&D 3.14, 4:10, 5.13, 6.15, 8.16, Date.
Computer Science 209 Graphics and GUIs.
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
25 GUI Example.
Applets & Applications
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Applets.
A+ Computer Science METHODS.
A+ Computer Science METHODS.
Introduction to Graphical Interfaces in Java: AWT and Swing
Just Basic Lesson 15 Mr. Kalmes.
Let us Flex our Gooey Guis, Sire
Lecture 4: Standard Java Graphics
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

GUI AND GRAPHICS

CLASS LIBRARIES import java.awt.Graphics; import javax.swing.JPanel; import javax.swing.JFrame;

HOW DO WE DRAW? Graphics: reference for shapes, contains the paintComponent JPanel: provides an area to draw JFrame: Holds and displays the panel

A Simple Application Window A stand-alone GUI (Graphical User Interface) application runs in a window. Code for application window exists in class ‘JFrame’

Main Class JFrame Create a window Set the frame to exit Add panel to frame Set the size of the frame Make the frame visible

Code for Application Window

Displaying ‘MyClass’ Panel This happens in the main class Create a window (JFrame) with an object to call ‘MyClass’ Window has specifications

‘MyClass’ extends JPanel Create a new class – Panel to be displayed MyClass for drawing must extend JPanel Inheritance relationship, ‘MyClass’ will begin with existing members of class JPanel JPanel is the superclass ; MyClass is the subclass

paintComponent Method Every JPanel contains a paintComponent method Used to display panel Syntax: public void paintComponent( Graphics g) Requires one argument, a Graphics object: super.paintComponent(g);

Create a New Class to hold Panel

Add Panel to Frame