Big Java, Binder Ready Version: Early Objects
Big Java, Binder Ready Version: Early Objects
6th Edition
ISBN: 9781119056447
Author: Cay S. Horstmann
Publisher: WILEY
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 2.9, Problem 44SC

Explanation of Solution

Refer the example “section_9_2/ RectangleComponent.java” which describes about how to display the component. In that program, let modify the line numbers “18” and “24” which contains the graphics2D object “g2” to “g”, then the following code displays the compiler error.

Code:

//Import the required java packages

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Rectangle;

import javax.swing.JComponent;

//Define the method to draw the component

public class RectangleComponent extends JComponent

{

    //Define the method paintComponent()

    public void paintComponent(Graphics g)

     {

         // Recover Graphics2D

         Graphics2D g2 = (Graphics2D) g;

         // Construct a rectangle 

         Rectangle box = new Rectangle(5, 10, 20, 30);

   //Draw the rectangle

         g.draw(box);

         /* Move rectangle 15 units to the right and 25

 units down*/

         box.translate(15, 25);

         // Draw moved rectangle

         g.draw(box);

     }

 }

File name: “Square.java”

//Import the required package

import javax.swing.JFrame;

//Declare the class "Square"

public class Square

{

    //Define the main function

    public static void main(String[] args)

    {

        //Create the object for JFrame class

        JFrame frame = new JFrame();

        //Set the size of the frame

        frame...

Blurred answer

Chapter 2 Solutions

Big Java, Binder Ready Version: Early Objects

Ch. 2.2 - Prob. 11SCCh. 2.2 - Prob. 12SCCh. 2.2 - Prob. 13SCCh. 2.3 - Prob. 14SCCh. 2.3 - Prob. 15SCCh. 2.3 - Prob. 16SCCh. 2.3 - Prob. 17SCCh. 2.3 - Prob. 18SCCh. 2.3 - Prob. 19SCCh. 2.3 - Prob. 20SCCh. 2.4 - How do you construct a square with center (100,...Ch. 2.4 - Prob. 22SCCh. 2.4 - Prob. 23SCCh. 2.4 - Prob. 24SCCh. 2.4 - Prob. 25SCCh. 2.5 - Prob. 26SCCh. 2.5 - Prob. 27SCCh. 2.5 - Prob. 28SCCh. 2.5 - Prob. 29SCCh. 2.5 - Prob. 30SCCh. 2.6 - Prob. 31SCCh. 2.6 - Prob. 32SCCh. 2.6 - Prob. 33SCCh. 2.6 - Prob. 34SCCh. 2.6 - Prob. 35SCCh. 2.7 - Prob. 36SCCh. 2.7 - Prob. 37SCCh. 2.8 - Prob. 38SCCh. 2.8 - Prob. 39SCCh. 2.9 - Prob. 40SCCh. 2.9 - Prob. 41SCCh. 2.9 - Prob. 42SCCh. 2.9 - Prob. 43SCCh. 2.9 - Prob. 44SCCh. 2.10 - Prob. 45SCCh. 2.10 - Prob. 46SCCh. 2.10 - Prob. 47SCCh. 2.10 - Prob. 48SCCh. 2.10 - Prob. 49SCCh. 2 - Prob. 1RECh. 2 - Prob. 2RECh. 2 - Prob. 3RECh. 2 - Prob. 4RECh. 2 - What is the value of mystery after this sequence...Ch. 2 - What is wrong with the following sequence of...Ch. 2 - Prob. 7RECh. 2 - Give an example of a method that has an argument...Ch. 2 - Write Java statements that initialize a string...Ch. 2 - Write Java statements that initialize a string...Ch. 2 - Write Java statements that initialize a string...Ch. 2 - Explain the difference between an object and an...Ch. 2 - Give the Java code for constructing an object of...Ch. 2 - Prob. 14RECh. 2 - Prob. 15RECh. 2 - Prob. 16RECh. 2 - Prob. 17RECh. 2 - Prob. 18RECh. 2 - Name two accessor methods and two mutator methods...Ch. 2 - Prob. 20RECh. 2 - Explain the difference between an object and an...Ch. 2 - Prob. 22RECh. 2 - Prob. 23RECh. 2 - Prob. 24RECh. 2 - Prob. 25RECh. 2 - Prob. 26RECh. 2 - Prob. 27RECh. 2 - Write an AreaTester program that constructs a...Ch. 2 - Write a PerimeterTester program that constructs a...Ch. 2 - Write a program that initializes a string with...Ch. 2 - Write a program that constructs a rectangle with...Ch. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - Prob. 7PECh. 2 - Prob. 8PECh. 2 - Prob. 9PECh. 2 - Prob. 10PECh. 2 - Prob. 11PECh. 2 - The Random class implements a random number...Ch. 2 - Prob. 13PECh. 2 - Look at the API of the Point class and find out...Ch. 2 - Using the Day class of Worked Example 2.1, write a...Ch. 2 - Prob. 16PECh. 2 - Prob. 17PECh. 2 - Prob. 18PECh. 2 - Prob. 19PECh. 2 - Prob. 20PECh. 2 - Prob. 1PPCh. 2 - Prob. 2PPCh. 2 - Prob. 3PPCh. 2 - Prob. 4PPCh. 2 - Prob. 5PPCh. 2 - Prob. 6PPCh. 2 - Prob. 7PPCh. 2 - Prob. 8PPCh. 2 - Prob. 9PPCh. 2 - Prob. 10PPCh. 2 - Prob. 11PPCh. 2 - Prob. 12PPCh. 2 - Prob. 13PPCh. 2 - Prob. 14PPCh. 2 - Prob. 15PP
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education