Concept explainers
Explanation of Solution
a.
Program:
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class drawRect extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Explanation of Solution
b.
Program:
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class fillrect extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Explanation of Solution
c.
Program:
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class drawoval extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Explanation of Solution
d.
Program:
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class drawline extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Explanation of Solution
e.
Program:
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class drawstrings extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Explanation of Solution
f.
Program:
package sample;
//import required packages
import javax.swing.*;
import java.awt.*;
//create a class that extends JApplet
public class polygon extends JApplet {
//init method
public void init() {
//to set the background color to white
getContentPane().setBackground(Color.white);
}
//paint method and g is the Graphics' object
public void paint(Graphics g) {
//calling the superclass
super...
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- Write a program that will use WheelsFX shapes to create a Car. Car must contain 6 parts (wheels, body, etc.) : Car must use 3 different kinds of shapes (Rectangle, Ellipse, etc.)arrow_forwardJava Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each part has one correct answer. Thank you. Part 1 - Which sets the frame (or a "form") width to 100 pixels and the height to 200 pixels? A. setSize(100, 200);B. setSize(200, 100);C. setDims(100, 200);D. setDimensions(200, 100);E. setWidth(100); setHeight(100); Part 2 - In Java, which can ensure the "Form" class to inherit from JFrame class? A. public class Form gets JFrame { }B. public class Form inherits JFrame { }C. public class Form extends JFrame { }D. public class Form : public JFrame { }E. public class Form implements JFrame { }arrow_forwardA problem using Turtle graphics: Draw an equilateral triangle with sides of 100 pixels starting at the origin having sides of 100 pixels. When the turtle stops, it should be pointing east. Your drawing should look like the shape below.arrow_forward
- Write an interactive program that gives you the option to generate one of the turtle graphics images. The program should prompt the user for a value between 1 and 5 and generate a corresponding turtle graphics image. If the user enters Q or q the program should terminate. If the user enters anything else appropriate error messages should be displayed.arrow_forwardPLEASE READ-THIS IS NOT FOR A GRADE!⚠️⚠️⚠️ Using the code below how would you code a Program that should display the average for the first semester and the second semester.Also posted an example Code: import tkinter # Let's create the Tkinter window. window = tkinter.Tk() window.title("GUI") # You will first create a division with the help of Frame class and align them on TOP and BOTTOM with pack() method. top_frame = tkinter.Frame(window).pack() bottom_frame = tkinter.Frame(window).pack(side = "bottom") # Once the frames are created then you are all set to add widgets in both the frames. btn1 = tkinter.Button(top_frame, text = "Button1", fg = "red").pack() #'fg or foreground' is for coloring the contents (buttons) btn2 = tkinter.Button(top_frame, text = "Button2", fg = "green").pack() btn3 = tkinter.Button(bottom_frame, text = "Button3", fg = "purple").pack(side = "left") #'side' is used to left or right align the widgets btn4 = tkinter.Button(bottom_frame, text =…arrow_forwardComputer Science JAVA (NOT KOTLIN) This must be done inside of Fragment with tab layout. The design of the tab: a. any image b. Add two thumbnails at top corners of the image above c. Allow the user to draw on screen, allow the user to select the pen thickness and color (give 3 options each), with a button to update the pen properties. d. Button to clear the drawing.arrow_forward
- Write the code that divides the screen into a grid of N by N squares. Use turtle graphics.arrow_forward(2) You will need to use the module graphics.py for this program. Write a program that con- structs a window, invites the user to present two clicks for the opposite vertices of a rectangle and then draws a red rectangle with those two opposite vertices. Finally, prompt the user to click to close the window.arrow_forwardExercise#2: Calculate the area and perimeter of right angled triangle.arrow_forward
- TestCircle• Create a Circle with the radius• Print the radius using the getters• Print the Circle’s area and circumference• Change the circle’s radius• Reprint the informationarrow_forwardCould anyone solve Chapter 3 #78 Gas Mileage from "An Introduction to Programming Using Visual Basic 11th edition. by David I. Schneider" please. "A motorist wants to determine her gas mileage at 23,352 miles (on the odometer) the tank is filled. At 23,695 miles the tank is filled again with 14 gallons. How many miles per gallon did the car average between the two fillings?" I need the code and a screenshot of the outcome. Thank you.arrow_forwardUsing C# in Microsoft Visual Studio create an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors…arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage