Description and Objective

This app consists of the following parts:

1. Create the GUI and draw an arrow icon in the canvas as shown in the picture below: See image.

The arrow can be drawn as a Polygon object by defining the (x,y) coordinates of the following points: See image.

The "Blink" button should run a thread that draws the icon in fixed intervals, which will make the icon look like it appears and disappears. Take a look at the BlinkingLight.java example that we did in class.

The text of the button should toggle between "Blink" and "Stop".

Do not worry about making your GUI look exactly like the one shown in the image. The functionality is more important for this lab.

The buttons at the bottom of the window do not need to be functional for this part

2. Add transformation functionality to the buttons and keys.

In order to add these functionalities, first you have to define ActionListener objects for each button, then override the paintComponent method of the drawing area and use the Graphics2D and AffineTransform objects to modify the scale, rotation, and position of the arrow shape.

The buttons should cause the icon to be redrawn close/far and rotate clockwise/counter-clockwise.

When the program starts the text on top of the drawing area should inform the user to click on the area to move the icon. Once the area is clicked this text should change, explaining how to move the icon (using arrow keys, or a,w,s,d keys). In order to get this functionality to work, you have to implement both the FocusListener and the MouseListener interfaces in addition to the KeyListener interface. Once the mouse is clicked, call requestFocus() method in order to process keyEvents.

As an example, below picture shows the GUI after applying a combination of rotate, scale and translate methods: See image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.