zoukankan      html  css  js  c++  java
  • 圆类-内部类多线程刷新

    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);
                }
            }
        }
    }
  • 相关阅读:
    eslint自动格式化
    焕肤功能
    Web Components
    Webpack 中的 sideEffects
    andriod 新建Activity_ Form
    那么唯美
    C# PDF添加水印
    停止触发器
    sp_sys_ERPTrigger_base
    sql语句返回主键SCOPE_IDENTITY()
  • 原文地址:https://www.cnblogs.com/yoyo198212/p/8302490.html
Copyright © 2011-2022 走看看