animatingsurface.java

来自「风机在线监测系统,采用sqlserver数据库,有问题联系我」· Java 代码 · 共 57 行

JAVA
57
字号
package java2d;/** * Demos that animate extend this class. */public abstract class AnimatingSurface extends Surface implements Runnable {    public Thread thread;    public abstract void step(int w, int h);    public abstract void reset(int newwidth, int newheight);    public void start() {        if (thread == null) {            thread = new Thread(this);            thread.setPriority(Thread.MIN_PRIORITY);            thread.setName(name + " Demo");            thread.start();        }    }    public synchronized void stop() {        if (thread != null) {            thread.interrupt();        }        thread = null;        max = (float) 0.0;        notifyAll();    }    public void run() {        Thread me = Thread.currentThread();        while (thread == me && !isShowing() || getSize().width == 0) {            try {                thread.sleep(500);            } catch (InterruptedException e) {}        }        while (thread == me) {            repaint();            try {                thread.sleep(500);            } catch (InterruptedException e) {}        }        thread = null;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?