1). Write a java program that use the Canvas class to produce patterns by updating the code below. Where appropriate, use this.getWidth() and this.getHeight() so that the output will looks the same regardless of the window size. Use fill rectangle commands to produce/draw flag of France. The vertical stripes are same (blue, white, red), they are of the same size, and the same width as well. import java.wat.; import javax.swing.JFrame; public class DisplayGraphics extends Canvas { public static void main (String [] args) { DisplayGraphics m=new DisplayGraphics(); jFrame f=new JFrame (); f.add(m); f.setSize (400,400); f.setVisible (true);   public void paint (Graphics g)  {   g.setColor(Color.blue) g.drawRec(400, 400, 100, 50); g.fillRec(400, 0, 100, 50); g.setColor(Color.white); g.drawRec(400, 400, 100, 50); g.fillRec(); g.setColor(Color.red); g.drawRec(400, 400, 100, 50); g.fillRec(); } 2). Write a java program will draw/produce a concentric circle based on the requirements below.  The concentric circle have a small circle in the center and gets bigger and bigger as it goes out. The radii of the circle get bigger as it go out or establish a beginning radius radius for the circle that go down to the center of the circle. Leave a little gap in between the circles to avoid getting solid or black circle. Draw the outer circle that will decrease the size or the radius of the circle the next circle and decrease it by the same amount each step using the for loop. 3). Write a java program that implement the below specification: Set the drawing color to green. Connect pixel (0,0) to every 5th pixel on the right border of the applet window by drawing a line between them, then set the drawing color to black. Connect the pixel in the upper right-hand corner of the applet window to every 5th pixel on the left border by drawing a line between them. The y will start at 0 and go by 5 and then x will be get width to what the x change by (0, 0) and then to get width and then y where y is incremented by 5 at a time 4). Write a java program that implements the below. Use the fillRec and other methods to draw the flag of United States Draw the stripes first and draw a blues rectangle which contains the stars. Or use small boxes or small circles for the stars.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1). Write a java program that use the Canvas class to produce patterns by updating the code below.

  • Where appropriate, use this.getWidth() and this.getHeight() so that the output will looks the same regardless of the window size.
  • Use fill rectangle commands to produce/draw flag of France. The vertical stripes are same (blue, white, red), they are of the same size, and the same width as well.

import java.wat.;

import javax.swing.JFrame;

public class DisplayGraphics extends Canvas {

public static void main (String [] args) {

DisplayGraphics m=new DisplayGraphics();

jFrame f=new JFrame ();

f.add(m);

f.setSize (400,400);

f.setVisible (true);

 

public void paint (Graphics g) 

{

 

g.setColor(Color.blue)

g.drawRec(400, 400, 100, 50);

g.fillRec(400, 0, 100, 50);

g.setColor(Color.white);

g.drawRec(400, 400, 100, 50);

g.fillRec();

g.setColor(Color.red);

g.drawRec(400, 400, 100, 50);

g.fillRec();

}

2). Write a java program will draw/produce a concentric circle based on the requirements below.  The concentric circle have a small circle in the center and gets bigger and bigger as it goes out.

  • The radii of the circle get bigger as it go out or establish a beginning radius radius for the circle that go down to the center of the circle.
  • Leave a little gap in between the circles to avoid getting solid or black circle.
  • Draw the outer circle that will decrease the size or the radius of the circle the next circle and decrease it by the same amount each step using the for loop.

3). Write a java program that implement the below specification:

  • Set the drawing color to green.
  • Connect pixel (0,0) to every 5th pixel on the right border of the applet window by drawing a line between them, then set the drawing color to black.
  • Connect the pixel in the upper right-hand corner of the applet window to every 5th pixel on the left border by drawing a line between them.
  • The y will start at 0 and go by 5 and then x will be get width to what the x change by (0, 0) and then to get width and then y where y is incremented by 5 at a time

4). Write a java program that implements the below.

  • Use the fillRec and other methods to draw the flag of United States
  • Draw the stripes first and draw a blues rectangle which contains the stars.
  • Or use small boxes or small circles for the stars.
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Array
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education