-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics1.java
More file actions
30 lines (28 loc) · 904 Bytes
/
Graphics1.java
File metadata and controls
30 lines (28 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Created by fattyduck on 4/12/15.
*/
import java.awt.*;
import javax.swing.JFrame;
public class Graphics1 extends Canvas {
public void paint(Graphics g){
g.setColor(Color.green);
g.drawRect(50,20,100,200);
g.fillOval(160,20,100,200);
g.setColor(Color.blue);
g.fillRect(200,400,200,20);
g.drawOval(200, 430, 200, 100);
g.setColor(Color.black);
g.drawString("Graphics are pretty neat. ", 500,100);
int x= getWidth()/2;
int y=getHeight()/2;
g.drawString("The first letter of this String is at ("+x+","+y+")",x,y);
}
public static void main(String[] args){
JFrame win= new JFrame("Graphics1");
win.setSize(800,600);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Graphics1 canvas = new Graphics1();
win.add(canvas);
win.setVisible(true);
}
}