Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 1, Problem 4E
Program Plan Intro
Question reference: Refer to Chapter 1, Exercise 1.4 to invoke the changeColor() method of the circular object and enter the string “red� as the parameter, and then try other colors as well.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write down four more color constants that are available in the Color class. Refer to the class’s documentation to find out what they are.
Add two new buttons that will be used to enlarge or shrink the circle, placing these buttons below the others. The text on these buttons can be simply “Enlarge” and “Shrink”. The size of a circle object is determined by the radius property, and the Circle class provides two methods to access and change its radius. Assuming c refers to a circle object, c.getRadius() returns the current radius of the circle; c.setRadius(r) changes the radius of the circle to the value r. You will need to add event handlers for the Enlarge and Shrink buttons, which should increase or decrease the radius of the circle by 10 pixels each time that the button is clicked. Remember that the handler for each button must be activated by invoking the setOnAction method, as we did for the other buttons. The code to handle these events will need to be added by creating two new branches inside the handle method of your program. • For the Shrink button, add a condition to the handler, to prevent the circle from…
Invoke the changeColor method, and write the color into the parameter field without the quotes. What happens?
Chapter 1 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 1 - Prob. 1ECh. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - Prob. 4ECh. 1 - This is a very simple example, and not many colors...Ch. 1 - Prob. 6ECh. 1 - Prob. 7ECh. 1 - Prob. 8ECh. 1 - Prob. 9ECh. 1 - Select Show Terminal from the View menu. This...
Ch. 1 - Select Show Code Pad from the View menu. This...Ch. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - Look at the pop-up menu of class Picture again....Ch. 1 - In the source code of class Picture, find the part...Ch. 1 - Add a second sun to the picture. To do this, pay...Ch. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Create an object of class Student. You will notice...Ch. 1 - Prob. 22ECh. 1 - Prob. 23ECh. 1 - Call the numberOfStudents method of that class....Ch. 1 - Look at the signature of the enrollStudent method....Ch. 1 - Prob. 26ECh. 1 - Prob. 27ECh. 1 - Prob. 28ECh. 1 - Prob. 29ECh. 1 - In this chapter we have mentioned the data types...Ch. 1 - What are the types of the following values?...Ch. 1 - Prob. 32ECh. 1 - Write the header for a method named send that has...Ch. 1 - Prob. 34ECh. 1 - Prob. 35ECh. 1 - Prob. 36E
Knowledge Booster
Similar questions
- How many times would you need to call the timeTick method on a newly created ClockDisplay object to make its time reach 01:00? How else could you make it display that time?arrow_forwardPLEASE ENSURE TO USE THE FRAMEWORK PROVIDED IN THE IMAGES, AND THAT IT WORKS WITH THE TESTER CLASS. Write a class RangeInput that allows users to enter a value within a range of values that is provided in the constructor. An example would be a temperature control switch in a car that allows inputs between 60 and 80 degrees Fahrenheit. The input control has “up” and “down” buttons. Provide up and down methods to change the current value. The initial value is the midpoint between the limits. As with the preceding exercises, use Math.min and Math.max to limit the value. Write a sample program that simulates clicks on controls for the passenger and driver seats.arrow_forwardAdd the purple code to your Main Code Section (type it by hand if you get weird errors). It will call the object’s monitorLevels() method, which we will create in this sprint: userInput = 99while userInput != 0:checkerObj.displayList()userInput = checkerObj.displayMenu()if(userInput == 1):checkerObj.addLevel()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 2):checkerObj.removeLevel()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 3):checkerObj.removeAllLevels()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 4):checkerObj.updateMenuPrice() elif(userInput == 5):userInput = 0 # prevent the app from continuing if the user pressed Ctrl+C to stop itcheckerObj.monitorLevels()arrow_forward
- .In class DrawDemo, create a new method named -drawTriangle. This method should create a pen (as in the drawSquare method) and then draw a green triangle.arrow_forwardNeed help with the following: Adding comments to help explain the purpose of methods, classes, constructors, etc. to help improve understanding. Implementing enhanced for loop (for each loop) to iterate over the numbers array in the calculateProduct method. Creating a separate class for the UI and a separate class for the calculator logic. Lastly, creating a constant instead of hard coding the number "5" in multiple places. Thank you for any input/knowldge you can transfer to me, I appreciate it. Source Code: package implementingRecursion; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class RecursiveProductCalculator extends JFrame { private JTextField[] numberFields; private JButton calculateButton; private JLabel resultLabel; public RecursiveProductCalculator() { setTitle("Recursive Product Calculator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new GridLayout(7, 1)); numberFields = new…arrow_forwardSearch a graphic method online and take a screenshot of it. Cite your reference.arrow_forward
- Create a canvas. Using the canvas’s methods interactively, draw a red circle near the center of the canvas. Now draw a yellow rectangle.arrow_forwardSuppose you would like an application that displays a green square inside a black circle. Write a paint() method that will draw the image.arrow_forwardPlease fix these in the above splution, it is not fully correct. "You're invited" needs to be formatted correctly. With a larger font, using BS classes only. Use Bootstrap classes to make a circular image with a border - around the image only. "Don't tell the cats" color should be set with BS classes.arrow_forward
- How do you get the current mouse location from the event object?arrow_forwardCreate the design for determining if a point is inside, on, or outside of the rectangle. Drawing out the rectangle and labeling the coordinates of all points will help you to visualize the problem. Once the design has been completed, write a program that prompts the user for the x and y coordinates for the lower left hand corner of a rectangle as well as the height and the width of the rectangle. After that, you will need to get the coordinates for the point from the user as well. Once all inputs have been entered by the user, determine if the point is inside the rectangle, on the rectangle, or outside the rectangle. If the point is inside the rectangle, print "inside the rectangle". If the point is on the rectangle, print "on the rectangle". If the point is outside of the rectangle, print "outside the rectangle". Example output: Enter the x coordinate of the lower left hand corner of the rectangle: 1 Enter the y coordinate of the lower left hand corner of the rectangle: 1 Enter the…arrow_forwardHow do you draw a line with an arrowhead?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT