分享一段代码:
主方法
import java.sql.SQLOutput;
import java.util.*;
import java.awt.*;
public class hello {
public static void main(String []avgs) {
Frame f=new Frame();
f.setTitle("表白");
f.setSize(800,800);
panel p=new panel();
f.add(p);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
类方法:
import java.awt.*;
public class panel extends Panel {
public void paint(Graphics g) {
Font f=new Font("黑体",Font.ITALIC,50);
g.setFont(f);
g.drawString("宝马",300,100);
Color c=new Color(0,0,0);
g.setColor(c);
g.fillOval(225,200,300,300);
Color c1=new Color(255,255,255);
g.setColor(c1);
g.fillOval(250,225,250,250);
Color c2=new Color(0,0,255);
g.setColor(c2);
g.fillArc(250,225,250,250,90,90);
g.fillArc(250,225,250,250,270,90);
}
}