Clicker quick questions 10/17/13 CSE 1102 Fall 2013.

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

Web Design & Development Lecture 19. Java Graphics 2.
Frame Windows A frame object is used to create a graphical frame window. This frame is used to show information in a graphical application. The JFrame.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Chapter 5 Programming Graphics. Chapter Goals To be able to write simple applications To display graphical shapes such as lines and ellipses To use colors.
Chapter 5 Programming Graphics. Chapter Goals To be able to write applications with simple graphical user interfaces To display graphical shapes such.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
1 Abstract Classes & Inheritance Hierarchies. 2 Abstract classes & methods Keyword abstract applied to a class guarantees that subclass must be constructed.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Slides prepared by Rose Williams, Binghamton University Chapter 19 Swing II.
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.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics F The architecture.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Swing Graphics ● Empty Swing containers have no visual appearance except for a background color ● Every JComponent must have a paintComponent method that.
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.
1 Interface Types & Polymorphism & introduction to graphics programming in Java.
1 Graphical User Components (II) Outline JTextArea Creating a Customized Subclass of JPanel JPanel Subclass that Handles Its Own Events Windows: Additional.
Introducing Graphics There are generally two types of graphics facilities in Java –Drawing –GUIs We concentrate on drawing here We will draw on a Graphics.
Object-Oriented Programming (Java), Unit 19 Kirk Scott 1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Screen Saver Application.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
tiled Map Case Study: Rendering with JPanel © Allan C. Milne v
Java Graphics Swing Graphics
Graphics and Java 2D. 2 Introduction Java’s graphics capabilities –Drawing 2D shapes –Controlling colors –Controlling fonts Java 2D API –More sophisticated.
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.
Graphics Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data.
© A+ Computer Science - Chicken yeller = new Chicken();
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
1 Block1 – unit 2 (The Case study in Budd 5-6).  create a small application that uses the Abstract Windowing Toolkit (AWT)  Swing packages to simulate.
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.
-Sai Phalgun Tatavarthy. Outline What is a “Graphing Calculator”? Graphics, Graphics2D classes Methods of Graphics object Custom Painting The paintComponent()
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
(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)
Clicker questions 10/24/13 CSE 1102 Fall θ (x,y) (0,0) What is the relationship between θ and (x,y) ? A.y = mx + b B.θ = x 2 + y 2 C.tan(θ) = x/y;
Introduction to Java Chapter 8 - Introduction to Java Graphics1 Chapter 8 Introduction to Java Graphics.
Java Dynamic Graphics.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
Review_6 AWT, Swing, ActionListener, and Graphics.
Chapter 5 Programming Graphics. Chapter Goals To be able to write simple applications To display graphical shapes such as lines and ellipses To use colors.
Lecture 3.1 Using Graphics with JFrame. © 2006 Pearson Addison-Wesley. All rights reserved javax.swing.JFrame - int x - int y - int width - int.
Java Swing One of the most important features of Java is its ability to draw graphics.
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Clicker quiz 9/17/13 CSE 1102 Fall // In Blob: public void mousePressed(MouseEvent e){ this.setFillColor(java.awt.Color.blue); } // in WinkingBlob.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
C Sc 335 Object-Oriented Programming and Design Rick Mercer
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Break Time! Graphical User Interface (GUI) NO EXAM….ONLY PROJECT!
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
Clicker quiz 10/22/13 CSE 1102 Fall 2013.
Java Graphics.
Java Graphics CS 2511.
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
GUI AND GRAPHICS.
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
A+ Computer Science METHODS.
A+ Computer Science METHODS.
Presentation transcript:

Clicker quick questions 10/17/13 CSE 1102 Fall 2013

A.They needed an Ellipse that would work on a smart phone B.They wanted an Ellipse that could move around the screen C.They wanted an Ellipse that could draw itself [CORRECT] D.StupidEllipse was already taken E.None of the above In chapter 7, why do the authors define a SmartEllipse class?

Modifier and TypeMethod and Description Rectangle2D getBounds2DgetBounds2D() Returns a high precision and more accurate bounding box of the Shape than the getBounds method. double getHeightgetHeight() Returns the height of the framing rectangle in double precision. double getWidthgetWidth() Returns the width of the framing rectangle in double precision. double getXgetX() Returns the X coordinate of the upper-left corner of the framing rectangle in double precision. double getYgetY() Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision. boolean isEmptyisEmpty() Determines whether the RectangularShape is empty. void setFramesetFrame(double x, double y, double w, double h) Sets the location and size of the framing rectangle of this Shape to the specified rectangular values. Methods inherited from class java.awt.geom.Ellipse2DEllipse2D containscontains, contains, equals, getPathIterator, hashCode, intersectscontainsequalsgetPathIteratorhashCodeintersects Methods inherited from class java.awt.geom.RectangularShapeRectangularShape cloneclone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, getPathIterator, intersects, setFrame setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonalcontains getBoundsgetCenterXgetCenterYgetFramegetMaxXgetMaxYgetMinXgetMinY getPathIteratorintersectssetFrame setFrameFromCenter setFrameFromDiagonal

A.JWindow B.JFrame C.JPanel [CORRECT] D.JContainer E.Canvas The thing you draw on in Swing is _______, or one of its subclasses.

What is the purpose of line 2? A.It calls the superclass constructor B.It ensures that the code in paintComponent(Graphics) of its superclass is executed as soon as this method is called [CORRECT] C.It ensures that the code in paintComponent(Graphics) of its superclass is executed after the code in this method D.It calls the default paintComponent(Graphics) for this class E.None of the above Consider the following code fragment (line numbers added) from BallApp – assume java.awt.* included: 1.public void paintComponent(Graphics aBrush) { 2.super.paintComponent(aBrush); // more code goes here 4.}

Clicker questions 10/17/13 CSE 1102 Fall 2013

A.paintComponent calls repaint() B.paintComponent has a parameter of type Graphics [CORRECT] C.repaint() calls paintComponent D.paintComponent is a method of the Graphics class E.None of the above How are Graphics, paintComponent, and repaint() related?

A.It places a Red Ball in the JFrame B.It provides a place to draw things within the frame [CORRECT] C.It opens a window on the display D.It puts a banner message on the screen E.none of the above 1.public class BallApp extends javax.swing.JFrame { 2.public BallApp (String title) { 3.super(title); 4.this.setSize(600, 450); 5.this.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE); 6.this.add(new BallPanel()); 7.this.setVisible(true); 8.} 9.public static void main (String [ ] args) { 10.BallApp app = new BallApp ( 11."*Now* you can change the banner!"); 12.} 13.} What is the purpose of this BallPanel added in line 6?

A.When the BallPanel is constructed B.When the user invokes it directly C.When the panel's container causes it to be invoked [CORRECT] D.When the panel asks for it to be invoked [CORRECT] E.More than one of the above is true [CORRECT] 1.public class BallPanel extends javax.swing.JPanel { 2.private SmartEllipse _ball; // components 3.public BallPanel () { 4.super(); 5.this.setBackground(java.awt.Color.white); 6._ball = new SmartEllipse (java.awt.Color.red); 7._ball.setLocation(75,75); 8._ball.setSize(60,60); 9.} 10.public void paintComponent (java.awt.Graphics aBrush) { 11.super.paintComponent(aBrush); 12.java.awt.Graphics2D betterBrush = 13.(java.awt.Graphics2D) aBrush; 14._ball.fill(betterBrush); 15.} 16.} When does paintComponent (lines 10-15) get invoked?

A.It identifies the type of aBrush B.It provides an alternative to using aBrush C.It is a parameter to pass to aBrush D.It produces a version of aBrush that is really a Graphics2D [CORRECT] E.None of the above is true 1.public class BallPanel extends javax.swing.JPanel { 2.private SmartEllipse _ball; // components 3.public BallPanel () { 4.super(); 5.this.setBackground(java.awt.Color.white); 6._ball = new SmartEllipse (java.awt.Color.red); 7._ball.setLocation(75,75); 8._ball.setSize(60,60); 9.} 10.public void paintComponent (java.awt.Graphics aBrush) { 11.super.paintComponent(aBrush); 12.java.awt.Graphics2D betterBrush = 13.(java.awt.Graphics2D) aBrush; 14._ball.fill(betterBrush); 15.} 16.} What does (java.awt.Graphics2D) do in line 13?

A.It instantiates the color of aBrush B.It provides a starting point if we want to change something's color C.It specifies the color that the SmartEllipse should be filled with or drawn D.It specifies the color that aBrush was before we draw or fill a SmartEllipse [CORRECT] E.None of the above 1.// SmartEllipse continued 2.public void fill (java.awt.Graphics2D aBetterBrush){ 3.java.awt.Color savedColor = aBetterBrush.getColor(); 4.aBetterBrush.setColor(_fillColor); 5.aBetterBrush.fill(this); // paint a solid ellipse 6.aBetterBrush.setColor(savedColor); 7.} 8.public void draw (java.awt.Graphics2D aBrush) { 9.java.awt.Color savedColor = aBrush.getColor(); 10.aBrush.setColor(_borderColor); 11.java.awt.Stroke savedStroke = aBrush.getStroke(); 12.aBrush.setStroke(new java.awt.BasicStroke(STROKE_WIDTH)); 13.aBrush.draw(this); 14.aBrush.setStroke(savedStroke); 15.aBrush.setColor(savedColor); 16.} 17.} In these methods, what is the purpose of the variable savedColor?

A.Window B.Frame C.JPanel D.JFrame [CORRECT] E.JWindow What is the basic window class in Swing?

A.Frame B.JComponent C.Container D.Component E.None of the above What is the least common ancestor of JFrame and JPanel?