public class Main extends JLabel{
JFrame f ;
Main(){
f= new JFrame("Flappy Bird");
f.setPreferredSize(new Dimension(500,500));
f.setMaximumSize(new Dimension(500,500));
f.setMinimumSize(new Dimension(500,500));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setResizable(true);
setOpaque(true);
setBackground(Color.red);
f.add(this);
f.setVisible(true);
f.pack();
}
void render() {
Graphics g = this.getGraphics();
g.setColor(Color.BLUE);
g.fillRect(0,0,50,50);
g.dispose();
repaint();
}
public static void main(String[] args) {
Main m = new Main();
m.render();
}
}
dlaczego nie przerysowuje mi tego niebieskiego kwadratu?