APL/APL2.1/TP07/Formes/NewPanel.java

29 lines
825 B
Java
Raw Normal View History

2022-03-08 17:15:30 +01:00
import javax.swing.*;
import java.awt.*;
public class NewPanel extends JComponent {
private Image circles;
public NewPanel() {
super();
this.circles = Toolkit.getDefaultToolkit().getImage("cercles.png");
}
@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.BLUE);
newBrush.drawRect(10, 10, 50, 50);
newBrush.drawImage(this.circles, 150, 50, this);
newBrush.setColor(Color.MAGENTA);
newBrush.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 24));
newBrush.drawString(">o<", 150, 50);
}
}