29 lines
760 B
Java
29 lines
760 B
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class Sablier extends JComponent {
|
||
|
public Sablier() {
|
||
|
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());
|
||
|
}
|
||
|
|
||
|
newBrush.setColor(Color.CYAN);
|
||
|
|
||
|
int[] x1 = {0, getWidth(), getWidth() / 2};
|
||
|
int[] y1 = {0, 0, getHeight() / 2};
|
||
|
|
||
|
int[] x2 = {0, getWidth(), getWidth() / 2};
|
||
|
int[] y2 = {getHeight(), getHeight(), getHeight() / 2};
|
||
|
|
||
|
newBrush.fillPolygon(x1, y1, 3);
|
||
|
newBrush.fillPolygon(x2, y2, 3);
|
||
|
}
|
||
|
}
|