TP07
This commit is contained in:
BIN
APL2.1/TP07/Cercles/Cercles.class
Normal file
BIN
APL2.1/TP07/Cercles/Cercles.class
Normal file
Binary file not shown.
20
APL2.1/TP07/Cercles/Cercles.java
Normal file
20
APL2.1/TP07/Cercles/Cercles.java
Normal file
@@ -0,0 +1,20 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Cercles {
|
||||
public static void main(String[] args) {
|
||||
JFrame f = new JFrame("Cercles");
|
||||
f.setSize(500, 500);
|
||||
f.setLocation(100, 100);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setLayout(null);
|
||||
|
||||
Circles c = new Circles();
|
||||
c.setSize(485, 460);
|
||||
c.setLocation(0, 0);
|
||||
f.add(c);
|
||||
|
||||
f.setResizable(false);
|
||||
f.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
APL2.1/TP07/Cercles/Circles.class
Normal file
BIN
APL2.1/TP07/Cercles/Circles.class
Normal file
Binary file not shown.
31
APL2.1/TP07/Cercles/Circles.java
Normal file
31
APL2.1/TP07/Cercles/Circles.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Circles extends JComponent {
|
||||
public Circles() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics brush) {
|
||||
Graphics newBrush = brush.create();
|
||||
|
||||
if (this.isOpaque()) {
|
||||
newBrush.setColor(this.getBackground());
|
||||
newBrush.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
for (int x = 0; x < 5; x++) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
Color c = new Color(0, 70 + 37 * y, 70 + 37 * x);
|
||||
int sizeX = getWidth() / 5;
|
||||
int sizeY = getHeight() / 5;
|
||||
|
||||
newBrush.setColor(c);
|
||||
newBrush.fillOval(sizeX * x, sizeY * y, sizeX, sizeY);
|
||||
newBrush.setColor(Color.WHITE);
|
||||
newBrush.fillOval(sizeX * x + sizeX / 4, sizeY * y + sizeY / 4, sizeX / 2, sizeY / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user