class Rect extends JPanel implements ActionListener , KeyListener,Runnable{
int x=2;
int y=3;
int a=1;
int b=0;
int aa;
public Rect(){
// this.setBackground(new Color(100,100,100));
}
//实现JPane的paint方法
public void paint (Graphics g){
//这个方法不可少
super.paint(g);
// g.drawRect(x,y,30,20);
g.setColor(new Color(a,b,aa));
if (a>50) a=1;
if (b>50) b=1;
if (true) aa=1;
System.out.print("颜色的值a="+a);
System.out.print("颜色的值b="+b); System.out.print("颜色的值aa="+aa); 这个变量aa的值为何这么怪异
g.fill3DRect(x, y, 30, 50, true);
System.out.println(x);
g.drawOval(x+30, y+30, 5, 5);
}
@Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
this.x++;
this.repaint();
System.out.println(x);
}
@Override
public void keyTyped(KeyEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode()==KeyEvent.VK_RIGHT)
{x++;