• 圆类-内部类多线程刷新


    package cn.test.circle;
    
    import java.awt.Color;
    import java.awt.Graphics;
    
    public class MyCircle {
        private int x ;
        private int y ;
        private int w ;
        private int h ;
        public MyCircle(int x, int y, int w, int h) {
            super();
            this.x = x;
            this.y = y;
            this.w = w;
            this.h = h;
            
            new MyCircleThread().start();
        }
        
        public void drawMe(Graphics g){
            g.setColor(Color.red);
            g.drawOval(x, y, w, h);
        }
        
        
        
        public int getX() {
            return x;
        }
    
        public void setX(int x) {
            this.x = x;
        }
    
        public int getY() {
            return y;
        }
    
        public void setY(int y) {
            this.y = y;
        }
    
        public int getW() {
            return w;
        }
    
        public void setW(int w) {
            this.w = w;
        }
    
        public int getH() {
            return h;
        }
    
        public void setH(int h) {
            this.h = h;
        }
    
    
    
        private class MyCircleThread extends Thread{
            @Override
            public void run() {
                super.run();
                while(true){
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    //不断改变属性值
                    x = (int)(Math.random()*100);
                    y = (int)(Math.random()*100);
                    w = (int)(Math.random()*100);
                    h = (int)(Math.random()*100);
                    
                    System.out.println("圆的内部在刷新坐标"+x+"--"+y+"---"+w+"---"+h);
                }
            }
        }
    }
  • 相关阅读:
    MySQL操作表中的数据
    mysql查询语句进阶
    mysql基本查询语句
    mysql函数
    mysql约束
    操作MySQL表
    操作MySQL数据库
    mysql视图
    as2 播放停止音效
    as3 深复制
  • 原文地址:https://www.cnblogs.com/yoyo198212/p/8302490.html
Copyright © 2020-2023  润新知