日期:2014-05-20  浏览次数:20715 次

请各位大侠帮忙!不胜感激!
import java.awt.*;
class MyCanvas extends Canvas{
public void pait(Graphics g){
g.setFont(new Font("华文行楷"),Font.PLAIN,20));
g.setColor(Color.RED);
g.drawString("绘图测试!",20,20);
g.drawLine(30,60,100,60);
g.draw3DRect(60,50,70,30,false);
g.setColor(Color.BLUE);
g.fillArc(0,60,65,65,40,80);
g.setFont(new Font("华文彩云",Font.PLAIN,30));
g.setColor(Color.PINK);
g.drawString("彩云之南",20,120);

}
}
public class AWTDrawing{
public static void main(String args[]){
Frame f = new Frame("AWT绘图");
MyCanvas p = new MyCanvas();
f.add(p);
f.setSize(170,170);
f.setBackgroud(new Color(160,220,220));
f.setVisible(true);

}
}
报错:--------------------Configuration: <Default>--------------------
C:\ex\12\AWTDrawing.java:4: ';' expected
g.setFont(new Font("华文行楷"),Font.PLAIN,20));
^
1 error

Process completed.
应该怎么处理?

------解决方案--------------------
g.setFont(new Font("华文行楷"),Font.PLAIN,20));

这一行括号不匹配
------解决方案--------------------
Java code

package test;

import java.awt.*;

class MyCanvas extends Canvas {
    public void paint(Graphics g) {//函数名写错了 paint
    g.setFont(new Font("华文行楷", Font.PLAIN, 20));// 注意括号
    g.setColor(Color.RED);
    g.drawString("绘图测试!", 20, 20);
    g.drawLine(30, 60, 100, 60);
    g.draw3DRect(60, 50, 70, 30, false);
    g.setColor(Color.BLUE);
    g.fillArc(0, 60, 65, 65, 40, 80);
    g.setFont(new Font("华文彩云", Font.PLAIN, 30));
    g.setColor(Color.PINK);
    g.drawString("彩云之南", 20, 120);


    }
}

public class AWTDrawing {
    public static void main(String args[]) {
    Frame f = new Frame("AWT绘图");
    MyCanvas p = new MyCanvas();
    f.add(p,BorderLayout.CENTER);
    f.setSize(170, 170);
    f.setBackground(new Color(160,220,220));//setBackground
    
    //f.pack();
    //f.validate();
    f.setVisible(true);

    }
}