Fin de tout
This commit is contained in:
29
DEV2.1/TP09/03_Rectangle/Rect.java
Normal file
29
DEV2.1/TP09/03_Rectangle/Rect.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Rect extends JComponent {
|
||||
|
||||
private int departX;
|
||||
private int departY;
|
||||
private int finX;
|
||||
private int finY;
|
||||
|
||||
public Rect(int departX, int departY, int finX, int finY) {
|
||||
this.departX = departX;
|
||||
this.departY = departY;
|
||||
this.finX = finX;
|
||||
this.finY = finY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
secondPinceau.setColor(Color.BLUE);
|
||||
secondPinceau.fillRect(this.departX, this.departY, this.finX-this.departX, this.finY-this.departY);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user