Assignment 05: GUI CSE 205 Fall 2021 1. What do you need to submit? (Minimal submitted files) You are required, but not limited, to tum in the following source files: • Main.java • DrawPanel.java 2....

1 answer below »
This assignment needs to be done in the Java Programming Language only. And all other instructions are in the pdf attached below


Assignment 05: GUI CSE 205 Fall 2021 1. What do you need to submit? (Minimal submitted files) You are required, but not limited, to tum in the following source files: • Main.java • DrawPanel.java 2. Requirements to get full credits in Documentation • The assignment number, your name, StudentID, and a class description need to be included at the top of each class/file. • A description of each method is also needed. • Some additional comments inside of methods to explain code that are hard to follow You can look at the Java programs in the textbook to see how comments are added to programs. 3. Skills to be Applied Java Swing: • Button Event handling • ComboBox Event handling • RadioButton Event handling • Mouse Event handling = Stack Data Structure 4. Program Description Write a Java Swing GUI application that creates the following window. The GUI should contain a color combo box (upper left comer) and three radio buttons ("Rectangle", "Circle" an "Arc"), two buttons (at the bottom, "Undo" & "Erase") and a canvas in cyan color where we can draw shapes on. Size of the window is about 500 x 500. If we click on the down arrow key of the combo box, we can pick a range of different colors, see below. At beginning the default color is "Black". For the three radio buttons, at beginning, the "Rectangle" radio button is picked. We can draw different color of rectangles by using mouse on canvas. If we switch the radio button to "Circle" or "Arc", then we can draw different color of circles or arcs on canvas: We can switch between "Rectangle", "Circle" and "Arc" so that different colored rectangles, circles, and arcs can be drawn on canvas freely. See the following picture as one example. First, we draw a black rectangle, we then draw a red rectangle, followed by a blue and a green circle, then we draw a yellow arc and last, we draw a pink arc. If we press the "Undo" button located at the bottom of the GUI, the last drawn shape, for this example, the pink arc will be removed from the canvas as below: If we press the "Undo" button one more time, the 2nd to the last shape - the yellow arc will also be removed from the canvas, see below: We can continue pressing the "Undo" button until all the shapes are removed the canvas as below: In case we draw several shapes with different colors on screen, such as the following picture shows: If we press the "Erase" button, all shapes will be erased from the canvas as follows: Moreover, when the user presses the mouse to start the drawing procedure, before they release the mouse button and during the dragging procedure, only the black outline of the shape will be drawn, the color of the shape during the dragging procedure should be white (see below left picture). A user can press and drag the mouse key in any directions, only after he/she released the mouse key, the picked color (from color combo box) should be filled (see below right picture). 5. Special Notes for Drawing Arcs We simplified drawing arcs procedure a little bit. When you pick the "Arc" radio button, the point where you press the mouse key will be the center of the arc, the startAngle of the arc will always be O degree; during the dragging procedure, the distance between the center point and the point where you dragged the mouse key is the arc's radiusX. radius Y will always be half of the radiusX. length of the arc can be computed by the following formular (see below picture). double anglelnRadians = Math.atan2(-dy, dx); double length = Math.toDegrees(anglelnRadians); 9. Grading Policy: • 10 points: submit assignment on time • 10 points: indicate assignment number, name, ASU id, lecture number, description of each class clearly in each submitted java file • 10 points: Program use comments properly to make grader easy to read/write. Your program should minimally have the following functionalities: • 10 points: program compiles. • 10 points: program generates the layout with the combo box, two radio buttons, the "Undo", "Erase" buttons and the canvas correctly. • 10 points: The color of the shape can be changed using the combo box. • 10 points: The shape can be changed using either of the two radio buttons. • 10 points: The "Undo" button correctly remove the last drawn shape and the "Erase" button correctly remove all shapes from canvas. • 20 points: On canvas, we can press-drag-release the mouse key to draw the relevant shape with correct color at the correct location on canvas.
Answered Same DayApr 26, 2022

Answer To: Assignment 05: GUI CSE 205 Fall 2021 1. What do you need to submit? (Minimal submitted files) You...

Anandkumar answered on Apr 27 2022
97 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here