-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawFrame.java
More file actions
48 lines (38 loc) · 1.18 KB
/
DrawFrame.java
File metadata and controls
48 lines (38 loc) · 1.18 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Zetsubou
*/
public class DrawFrame extends JFrame{
private static final long serialVersionUID = 1L;
public DrawFrame(){
setTitle("Fractals");
add(new DrawPanel());
}
public static void main(String[] args){
JFrame frame = new DrawFrame();
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class DrawPanel extends JPanel{
private static final long serialVersionUID = 1L;
protected void paintComponent(Graphics g){
super.paintComponent(g);
int xCenter = getWidth()/2;
int yCenter = getHeight()/2;
int radius = (int)(Math.min(getWidth(), getHeight())*0.4);
int x = xCenter - radius;
int y = yCenter - radius;
g.fillArc(x, y, 2*radius, 2*radius, 0, radius);
}
}