[REPOST] Instructions: (USE JAVA LANGUAGE) Kindly modify, add on where it is lacking and execute the java program provided below. Don't forget to provide a screenshot of the program output. SimpleGUI.java import java.awt.*; import javax.swing.JPanel; public class SimpleGUI extends JPanel {   //Contructor to have panel  public SimpleGUI(Color color, int length, int width) { super.setBackground(color); super.setPreferredSize(new Dimension(length, width));   }   public void paintComponent(Graphics page) {     super.paintComponent(page);     /* The coordinate system for the Java graphing window positions (0,0) in the upper left hand corner.       The grid is then numbered in a positive direction on the x-axis (horizontally to the right) and      in a positive direction on the y-axis (vertically going down).     We will now be using the methods contained within the Graphics Class in the package java.awt     */          //drawLine(int x1, int y1, int x2, int y2)     //draw a straight line from point (x1,y1) to (x2,y2).     page.setColor(Color.black);     page.drawLine(200, 10, 300, 30);     //exercise 1: craete your own line with different color, position and size     /* drawRect(int x, int y, int width, int length)     draw a rectangle with the upper left corner at (x,y) and with the specified width and length.     fillRect is the same as drawRect except just it is filled     */     page.setColor(Color.gray);     page.fillRect(60, 30, 100, 50);       //exercise 2: create your own rectangle     /*drawOval(int x, int y, int width, int length)     draw an oval inside an imaginary rectangle whose upper left corner is at (x,y).  To draw a circle keep the width and length the same.     */     page.setColor(Color.yellow); page.fillOval(120, 120, 120, 80);      page.setColor(http://Color.red); page.drawRect(120, 120, 120, 80);      //exercise 3: craete your own oval     /* drawArc(int x, int y, int width, int length,                int startAngle, int arcAngle)       draw an arc inside an imaginary rectangle whose upper left corner is at (x,y).  The arc is drawn from the startAngle to startAngle + arcAngle and is measured in degrees.        A startAngle of 0º points horizontally to the right (like the unit circle in math).  Positive is a counterclockwise rotation starting at 0º.      */     page.setColor(http://Color.blue);     page.fillArc(200, 50, 100, 50, 0, 90);     //exercise 4: craete your own arc     /* drawPolygon(int x[ ], int y[ ], int n)       draw a polygon created by n line segments.  The command will close the polygon.  (x-coordinates go in one array with accompanying y-coordinates in the other)     */     int [] x = {340, 250, 300};     int [] y = {110, 150, 170};     page.setColor(Color.pink);     page.drawPolygon(x, y, 3);     //exercise 5: craete your own polygon with 5 points     /* drawString(String str, int x, int y);       Draws a string starting at the point indicated by (x,y).  Be sure you leave enough room from the top of the screen for the size of the font.     */         page.setColor(Color.magenta);     page.drawString("Great Job!", 300, 230);     //exercise 6: craete your own message   } }

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

[REPOST] Instructions: (USE JAVA LANGUAGE) Kindly modify, add on where it is lacking and execute the java program provided below. Don't forget to provide a screenshot of the program output.

SimpleGUI.java

import java.awt.*;
import javax.swing.JPanel;

public class SimpleGUI extends JPanel {

  //Contructor to have panel 
public SimpleGUI(Color color, int length, int width) {
super.setBackground(color);
super.setPreferredSize(new Dimension(length, width));  
}

  public void paintComponent(Graphics page) {
    super.paintComponent(page);

    /* The coordinate system for the Java graphing window positions (0,0) in the upper left hand corner.  
    The grid is then numbered in a positive direction on the x-axis (horizontally to the right) and 
    in a positive direction on the y-axis (vertically going down).
    We will now be using the methods contained within the Graphics Class in the package java.awt
    */
    
    //drawLine(int x1, int y1, int x2, int y2)
    //draw a straight line from point (x1,y1) to (x2,y2).
    page.setColor(Color.black);
    page.drawLine(200, 10, 300, 30);
    //exercise 1: craete your own line with different color, position and size

    /* drawRect(int x, int y, int width, int length)
    draw a rectangle with the upper left corner at (x,y) and with the specified width and length.
    fillRect is the same as drawRect except just it is filled
    */
    page.setColor(Color.gray);
    page.fillRect(60, 30, 100, 50);  
    //exercise 2: create your own rectangle

    /*drawOval(int x, int y, int width, int length)
    draw an oval inside an imaginary rectangle whose upper left corner is at (x,y).  To draw a circle keep the width and length the same.
    */
    page.setColor(Color.yellow);
page.fillOval(120, 120, 120, 80); 
    page.setColor(http://Color.red);
page.drawRect(120, 120, 120, 80); 
    //exercise 3: craete your own oval

    /* drawArc(int x, int y, int width, int length,
               int startAngle, int arcAngle)
      draw an arc inside an imaginary rectangle whose upper left corner is at (x,y).  The arc is drawn from the startAngle to startAngle + arcAngle and is measured in degrees. 
      A startAngle of 0º points horizontally to the right (like the unit circle in math).  Positive is a counterclockwise rotation starting at 0º.
     */
    page.setColor(http://Color.blue);
    page.fillArc(200, 50, 100, 50, 0, 90);
    //exercise 4: craete your own arc

    /* drawPolygon(int x[ ], int y[ ], int n)
      draw a polygon created by n line segments.  The command will close the polygon.  (x-coordinates go in one array with accompanying y-coordinates in the other)
    */
    int [] x = {340, 250, 300};
    int [] y = {110, 150, 170};
    page.setColor(Color.pink);
    page.drawPolygon(x, y, 3);
    //exercise 5: craete your own polygon with 5 points

    /* drawString(String str, int x, int y);
      Draws a string starting at the point indicated by (x,y).  Be sure you leave enough room from the top of the screen for the size of the font.
    */    
    page.setColor(Color.magenta);
    page.drawString("Great Job!", 300, 230);
    //exercise 6: craete your own message

  }
}

 

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Binary numbers
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