CS324e - Elements of Graphics and Visualization Java GUIs - Frames and Panels.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Lecture 3 A First Graphic Program. Features of a simple graphic program.
Web Design & Development Lecture 19. Java Graphics 2.
Mouse Listeners We continue our examination of GUIs by looking at how to interact with the mouse –Just as Java creates Events when the user interacts with.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
Graphics Programming With Applets Feb 23, Applets There are three different types of executable java code. –Standalone application, which has main()
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Part 3: Design Days 15, 19, 21, 23 Chapter 8: Work Reengineering and Conceptual Design Chapter 9: Design Guidance and Design Rationale Chapter 10: Interaction.
Introduction to 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,
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Java Swing - Lecture 1 An Introduction Milena Radenkovic slides originally by Chris Coleman.
History of Computer-aided design (CAD) How did we get from… to here? here Bigkif. “Ivan Sutherland : Sketchpad Demo (1/2)” accessed accessed.
Written by Liron Blecher
Programming Fundamentals 2: Background/ F II Objectives – –give a non-technical overview of Java Semester 2, Background.
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.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
CompSci 230 S Software Construction Frameworks & GUI Programming.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Java Tutorial Ethan New York University.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
School of Computer Science & Information Technology G6DICP - Lecture 17 GUI (Graphical User Interface) Programming.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
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 Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Getting started with Programming using IDE. JAVA JAVA IS A PROGRAMMING LANGUAGE AND A PLATFORM. IT CAN BE USED TO DELIVER AND RUN HIGHLY INTERACTIVE DYNAMIC.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Java GUI building approaches Aleksandar Kartelj Faculty of Mathematics, Belgrade 11 th Workshop “Software Engineering Education and.
Applets Yong Choi School of Business CSU, Bakersfield.
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.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Graphics basic 1. 2 Objectives Understand Java coordinate systems. Draw things using the methods in the Graphics class. Override the paintComponent method.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Source Mastering UML with Rational Rose 2002 Information System Engineering Introduction to UML.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Review_6 AWT, Swing, ActionListener, and Graphics.
Java Swing One of the most important features of Java is its ability to draw graphics.
Source Mastering UML with Rational Rose 2002 Information System Engineering Introduction to UML.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Past Computing Environments: Swing Ian Smith UI Toolkits (History Lesson) 4 Programming tools for building interfaces 4 Originally in Java you had AWT.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
CompSci 230 S Software Construction
Lecture 27 Creating Custom GUIs
GUI AND GRAPHICS.
GUIS: Graphical User Interfaces
The AWT (versus Swing Components)
Java Applets.
Introduction to Graphical Interfaces in Java: AWT and Swing
Model, View, Controller design pattern
Lecture 4: Standard Java Graphics
Presentation transcript:

CS324e - Elements of Graphics and Visualization Java GUIs - Frames and Panels

Intro to Java GUIs First, a little history Vol Libre. Made by Loren Carpenter in Shown at SIGGRAPH

Vol Libre

Use of fractal (take a shape, split it into subparts, each subpart is the same general shape as the original) to generate things such as mountains, snowflakes, lightning. – We will generate a 3d fractal landscape later in the term

Computer Power Carpenter reported it took minutes of computer time to generate each frame of movie Machine was a VAX-11/780. – A mini computer with a speed of about 0.5 MIPS. (millions of instructions per second) Ball parking: 2 minutes * 60 sec / minute * 30 frames / sec * 30 minutes / frame = 75 days? Seems high. if frame rate were less, say 5 / sec answer is 12.5 days.

Computer Power The Vax 0.5 MIPS Intel Core 7 (high end) 177,730 MIPS ~350,000 times faster 12.5 days / 350,000 = about 3 seconds

Loren Carpenter Loren was an engineer at Boeing. He went to work at the computer division at Lucas Films. The computer division was eventually sold to Steve Jobs and evolved int Pixar instrumental in writing the software used to render Pixar movies

The Teapot Homage to the "Utah Teapot" A lot of early work in computer graphics was done at the University of Utah Martin Newell, 1975 – wanted a model of an ordinary object to test graphics engine / program

Java GUIs Java has huge library of built in classes – The API works with files, networking, databases, xml, cryptography, graphics, … AWT (Abstract Windowing Toolkit) and Swing

Sidetrack GUIs In the beginning, was the command line

GUIs As Computer use grew (rapidly) ease of use became an issue HCI, Human Computer Interaction GUIs Xerox Alto from PARC and Xerox Star – Macintosh – Windows

Back to Java GUIs - AWT early 90s, AWT was first attempt to provide ability to have graphics and GUIs in Java Approach was to have very little code in Java and instead map to components provided by host machine – use a Max button or a Windows button Java "Write Once, Run Everywhere" – "write once, debug everywhere"

Swing Sun and Java developers borrowed IFC (Internet Foundation Classes) from Netscape Everything written in Java, so not as platform dependent as AWT – still use parts of AWT for GUI programming

First Component use JFrame class – frames hold things main class to do "other stuff" creates a frame Inheritance sidetrack – creating a new data type based on a preexisting data type – get all of the existing methods! – inheritance in Java

HelloFrame Graphics Coordinate Systems

JPanel Frames holds things We will use panels as out canvas to draw (paint stuff) – painting metaphor very useful in Java graphics panel is like a frame and a canvas Panels can hold other things, but can we can also paint on them

HelloPanel Initial Version:

Try Drawing on Panel Naïve attempt: – get graphics object for panel – drawString method – x, y are of baseline of String – in constructor? – in start()? – what happens when frame resized?

Swing Rendering "Something" generates a paint request – such as resizing the frame A component, such as the frame will eventually have its paintComponent method called The component's children will also have their paintComponent method called back to front painting

Override paintComponent in HelloPanel what happens if don't call super.paintComponent? what happens when resized?