gann-cdf /
graphics
| 1 | package docs; |
||
| 2 | |||
| 3 | import org.gannacademy.cdf.graphics.geom.Ellipse; |
||
| 4 | import org.gannacademy.cdf.graphics.geom.Rectangle; |
||
| 5 | import org.gannacademy.cdf.graphics.ui.AppWindow; |
||
| 6 | |||
| 7 | import java.awt.*; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Build your app as an extension of the AppWindow class (which sets up the window and drawing panel for you) |
||
| 11 | */ |
||
| 12 | public class DrawingApp extends AppWindow { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Start your app by instantiating it in your main method |
||
| 16 | */ |
||
| 17 | public static void main(String[] args) { |
||
| 18 | new DrawingApp(); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Override the setup() method to define your drawing |
||
| 23 | */ |
||
| 24 | @Override |
||
| 25 | protected void setup() { |
||
| 26 | // draw a blue rectangle with a thick outline |
||
| 27 | Rectangle r = new Rectangle(200, 75, 200, 200, getDrawingPanel()); |
||
|
0 ignored issues
–
show
|
|||
| 28 | r.setFillColor(Color.BLUE); |
||
| 29 | |||
| 30 | // draw a red, transparent circle with a thick outline |
||
| 31 | Ellipse e = new Ellipse(250, 125, 200, 200, getDrawingPanel()); |
||
|
0 ignored issues
–
show
Use try-with-resources or close this "Ellipse" in a "finally" clause.
You may want to use Loading history...
|
|||
| 32 | e.setFillColor(new Color(255, 100, 100, 200)); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |
You may want to use
try {} ... finally {}to close the resource or use the (relatively) new try-with-resources capability.