Applet例子一个


package Graphics;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class Lines extends Applet implements MouseListener,Runnable {
 int x,y;
 public void init(){
  x=0;
  y=0;
 }
 public void start(){
//  System.out.println("start");
 }
// public void stop(){
//  System.out.println("stop");
// }
// public void destory(){
//  System.out.println("destory");
// }
 public void paint(Graphics g) {
  // g.drawLine(50, 50, 100, 100);
  // g.drawLine(50, 100, 100, 50);
//  g.setColor(Color.BLUE);
//  g.drawArc(50, 50, 100, 100, 0, 270);
//  g.drawRect(50, 50, 100, 100);
//  g.fillArc(50, 50, 100, 100, 0, 90);
//  g.drawOval(50, 50, 5,5);
//  g.fillOval(50, 50, 5, 5);
//  
//  g.drawOval(0, 0, 50, 150);
  this.addMouseListener(this);
  
  
    
  // 绘制椭圆的边框。
 }
 public void repaint(int x,int y){
//     Graphics g1;
//  g1 = getGraphics();
//   g1.drawLine(x, y, 100, 100);
 }
 

 public void mouseClicked(MouseEvent e) {
  x=e.getX();
  y=e.getY();
  System.out.println("x="+x);
        System.out.println("y="+y);
     Thread one;
       one = new Thread(this);
       one.start();
       one = null;
       }

 public void mouseEntered(MouseEvent arg0) {

 }

 public void mouseExited(MouseEvent arg0) {

 }

 public void mousePressed(MouseEvent arg0) {

 }

 public void mouseReleased(MouseEvent arg0) {

 }
 public void run()
 {
  for(int i=0;i<5;i++)
  {
    try{
     Thread.sleep(1000);
    
    }
    catch(InterruptedException e){
     System.out.println("中断错误");}
//    System.out.println("幸福的像花一样");
    Graphics g1;
    g1 = getGraphics();
     g1.drawOval(x, y, 10+2*i, 10+2*i);
//     g1.
  }
  
  
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值