import javax.swing.*;
import java.awt.*;
public class Fr extends JFrame{
Fr(String s){
super(s);
setSize(200,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics gr){
gr=getGraphics();
gr.fillRect(50, 50, 20, 20);
}
public static void main(String[] args){
Fr f=new Fr("Window");
f.getGraphics().setColor(JColorChooser.showDialog(null,"Color",null));
f.getGraphics().fillRect(100,100,20,20);
}
}
It creates a window, method "paint" draw first rect after creates window color selection, I choose the color (red) and drawn the second rect...black Why?