1、
package java_exam;
import java.awt.*;
public class a1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame();
f.setSize(500,400);
Mypanel my=new Mypanel();
f.add(my);
f.setVisible(true);
}
}
class Mypanel extends Panel{
public void paint(Graphics g){
g.setFont(new Font("宋体", 0, 30));
g.setColor(Color.blue);
g.drawString("地址:长春工业大学人文信息学院", 0, 50);
g.drawString("计算机科学与工程", 0, 100);
g.drawString("邮编:130122", 0, 150);
}
}
----------------------------------------------------------------------------------------------------
2、
package p2;
import java.awt.*;
public class a2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame();
f.setSize(400,300);
//f.setLocation(500, 500);
Mypanel md=new Mypanel();
f.add(md);
f.setVisible(true);
}
}
class Mypanel extends Panel{
public void paint(Graphics g){
g.setFont(new Font("隶书", 0, 20));
g.setColor(Color.green);
g.drawString("两个同心圆", 100, 150);
g.setColor(Color.green);
g.drawOval(225,175 , 35, 35);
g.drawOval(230,180 , 25, 25);
}
}
----------------------------------------------------------------------------------------------------
3、
package p3;
import java.awt.*;
public class a3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame();
f.setSize(300,500);
Mypanel my=new Mypanel();
f.add(my);
Thread t=new Thread(my);
t.start();
f.setVisible(true);
}
}
class Mypanel extends Panel implements Runnable{
//@Override
int x=60;
int y=130;
Boolean flag=true;
public void paint(Graphics g){
if(flag==true)
g.drawString("正在加载中", 30, 30);
else
g.drawString("加载完成", 30, 30);
g.setColor(Color.blue);
g.fillOval(x, y, 30, 30);
g.setColor(Color.gray);
g.drawRect(60,130 , 160, 30);
}
public void run() {
// TODO Auto-generated method stub
while(true){
x+=3;
if(x>190){
flag=false;