Explore BrainMass
Share

Java program to move a rectangle on mouse click

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Write an application that draws a rectangle within a panel as shown in the attachment p10.png .

When user clicks in a point left of the rectangle, it moves 10px to left. It also moves to right by 10px if user clicks on a point right to the rectangle. Clicking in any other areas such as above, inside or below the rectangle will do nothing.

I have to compile and execute the program at commandline in Java.

© BrainMass Inc. brainmass.com March 22, 2019, 2:10 am ad1c9bdddf
https://brainmass.com/computer-science/graphics/java-program-move-rectangle-mouse-click-565681

Attachments

Solution Preview

Please rename 565681-DrawRect.java as DrawRect.java before you compile and execute the ...

Solution Summary

Java compiler and Java version "1.7.0_21" were used during development and testing of the attached program. Response includes instructions to compile and execute the program at commandline.

$2.19