32 lines
800 B
Java
32 lines
800 B
Java
|
import javax.swing.JPanel;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class FunPanel extends JPanel {
|
||
|
private int table = 3;
|
||
|
private int limit = 150;
|
||
|
|
||
|
public FunPanel() {
|
||
|
super();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void paintComponent(Graphics g) {
|
||
|
Graphics gg = g.create();
|
||
|
|
||
|
if (this.isOpaque()) {
|
||
|
gg.setColor(getBackground());
|
||
|
gg.fillRect(this.getX(), this.getY(), getWidth(), getHeight());
|
||
|
}
|
||
|
|
||
|
double size = (double)getX();
|
||
|
System.out.println(size);
|
||
|
|
||
|
gg.setColor(Color.RED);
|
||
|
for (double i = 0; i < limit; i++) {
|
||
|
double theta = (i / (double)limit) * Math.PI * 2;
|
||
|
|
||
|
gg.fillOval((int)(Math.cos(theta) * size) + getX() / 2, (int)(Math.sin(theta) * size) + getY() / 2, 10, 10);
|
||
|
}
|
||
|
}
|
||
|
}
|