While we will not use most of the features of the AWT, it is a good idea to bookmark a few essential classes that may come in handy during the lab:
Create a new Java project in Eclipse and import the following file
/home/jimenezp/csc207/Lab-Drawing/DrawingPanel.java
Don’t worry if you don’t understand most of what is contained in this file. Mostly, we will use the constructor as a convenient, simplified means of starting our own GUI.
Create a new Java class that you will use to play around with creating a variety of shapes in order to get used to working with the DrawingPanel. You should include your main method in this file.
setBackground(color)
. You can use java.awt.Color
predefined colors, see the Color class documentation or Table 3G.3 from today’s reading.java.awt.Graphics
documentation or Table 3G.2 from today’s reading to get familiar with useful methods. The method that will draw a line is drawLine(x1, y1, x2, y2)
where x1
and y1
represent the starting point and x2
and y2
are the end point. The default color is black.
java.awt.Font
documentation or the table 3G.4-5.Create a new Java file in the same project. You will use this to create an image that repeats over the DrawingPanel.
The image colors should change gradually with each repetition of the image so that it produces a nice gradient effect. This will look best if you overlap the shapes slightly as they are drawn in sequence from top to bottom, for instance. You could do a gradient from black to white, if you wish, or try changing one of the color values (red, green, or blue) such as this fade from red to blue.
Now, take what you have learned so far and get creative!! Choose an image to create using the basic shapes you have learned. The choice of image is up to you, but consider a couple of starting points:
(4 points) Submit the source file for your complex Object/Scene and the output of your program along with a description of your figure/scene.
Remember: Do not use magic numbers, write your code anticipating errors and print user-friendly error messages, all your public methods should be well documented (use Javadoc comments). Please include comments or organize your code and report in a way that will help the grader to find the answer to the exercises or posted questions.