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.
1). Write a java
- 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.
Unlock instant AI solutions
Tap the button
to generate a solution