I am having a little trouble with my latest university assignment. (So don't give me the answer straight out if you got it just looking pointed in the right direction).
I have been tasked with creating a program that will show 3 different shapes:
- Square, Triangle, and Circle.
- Only 1 shape will be drawn on the screen at any one time.
- There are 2 calculations in text boxes at the bottom of the screen showing the area and boundary for the given shape.
- There is also a slider at the bottom of the screen and as it is moved the area and boundary calculation will change accordingly.
- The shapes and the calculations are connected into the relevant JMenuItem, changeAction Listener.
The problem I am having is the final stage that I am at now.
I need to be able to make the shapes being drawn to the screen repaint and take into account the slider value and add that onto the shape boundaries, therefore changing the size of the shape.
I have the shapes being created with the default values working correctly, and can hardcode in numbers to add to the coordinates to make the shapes scale as I would like.
I just need to get a way to pass values from the slider in the class MyControlPanel to the paintComponent method in the DrawShape class
Thanks in advance for any replies and taking the time to read this.
Stephen


Sign In
Create Account



Back to top









