import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;public class F {
public static void main(String[] args) {
ButtonFrame frame = new ButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class ButtonFrame extends JFrame {
JButton b= new JButton();
FillPanel p = new FillPanel();
public ButtonFrame() {
this.setSize(200,200);
this.add(b,BorderLayout.NORTH);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//p.repaint();这句无效
ButtonFrame.this.repaint();//貌似这句也无效
}
});
}
}
class FillPanel extends JPanel {
private int i;
protected void paintComponent(Graphics g) {
//super.paintComponent(g);
 System.out.println("paint");
g.drawString(i+"", 100, 100);
i++;

}
求问这是为什么啊