32 lines
745 B
Java
32 lines
745 B
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
class NewJFrame extends JComponent {
|
|
public NewJFrame() {
|
|
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(this.getForeground());
|
|
|
|
}
|
|
}
|
|
|
|
public class Formes {
|
|
public static void main(String[] args) {
|
|
JFrame f = new JFrame("Formes");
|
|
f.setSize(500, 500);
|
|
f.setLocation(100, 100);
|
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
f.setVisible(true);
|
|
}
|
|
} |