以下是代码。我在显示翻转图片的地方填充了红色,但是用Graphics2D总是不能正确显示,请问该如何解决?import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import java.awt.image.*;
public class ImageRote
{
    public static void main(String[] args)
    {
        JFrame frame = new TransformFrame();
        frame.setVisible(true);
    }
}
class TransformFrame extends JFrame implements ActionListener
{
    JButton rote = new JButton("旋转") ;
    JButton flipX= new JButton("flipX");
    JButton flipY= new JButton("flipY");    public TransformFrame()
    {
        setTitle("TransformTest");
        setSize(400, 400);
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });        Container contentPane = getContentPane();
        canvas = new TransPanel();
        contentPane.add(canvas, "Center");        JPanel buttonPanel = new JPanel();
        ButtonGroup group = new ButtonGroup();        buttonPanel.add(rote);
        group.add(rote);
        rote.addActionListener(this);        buttonPanel.add(flipX);
        group.add(flipX);
        flipX.addActionListener(this);        buttonPanel.add(flipY);
        group.add(flipY);
        flipY.addActionListener(this);        contentPane.add(buttonPanel, "North");
    }
    public void actionPerformed(ActionEvent event)
    {
        Object source = event.getSource();
        if (source == rote)
        {
            canvas.setRotate();
        } else
        if (source == flipX)
        {
            canvas.flipX();
        } else
        if (source == flipY)
        {
            canvas.flipY();
        }
    }    private TransPanel canvas;
}
class TransPanel extends JPanel
{
    boolean m_flipX = false ;
    boolean m_flipY = false ;
    int roteAngle = 0 ;    
    public TransPanel()
    {
        img = new ImageIcon("8.png").getImage();
    }    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);        Graphics2D g2 = null;
        g.drawImage(img, 0, 0, this); //画原图        BufferedImage buffer = new BufferedImage(img.getWidth(this),img.getHeight(this),BufferedImage.TYPE_INT_ARGB) ;
        g2 = buffer.createGraphics() ;
        g2.setColor(Color.red);
        g2.fillRect(0,0,buffer.getWidth(),buffer.getHeight());        if (m_flipX)
            g2.scale(-1,1);        if (m_flipY)
            g2.scale(1,-1);        if (roteAngle != 0)
            g2.rotate(Math.toRadians(roteAngle));        g2.drawImage(img,0,0,this) ;        g.drawImage(buffer,100,100,this) ;    }    public void setRotate()
    {
        roteAngle += 90 ;
        roteAngle %= 360 ;
        repaint();
    }    public void flipX()
    {
        m_flipX = !m_flipX ;
        repaint();
    }    public void flipY()
    {
        m_flipY = !m_flipY ;
        repaint();
    }    private Image img;
}