Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- MSsql
- MANTIS
- Java
- javascript
- C#
- Eclipse
- decompiler
- 웹뷰
- SpringSource Tool Suite
- STS
- Web Service
- 안드로이드
- 자바스크립트
- TextBox
- asp.net
- 자바
- 컬럼명
- 이클립스
- Bootstrap
- varags
- WebView
- MS-SQL
- scrollView
- Android
- Maven
- Apache Lucene
- jsp
- 웹 서비스
- html
- Redirect
Archives
- Today
- Total
bboks.net™
[자바 애플릿] 더블버퍼링 예제 본문
import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; public class TestDoubleBuffer extends Applet implements Runnable { int x, y; boolean posX, posY; Image offImg; Graphics gc; Thread thr; public void init() { this.x = 0; this.y = 0; this.posX = true; this.posY = true; } public void start() { offImg = this.createImage(this.getWidth(), this.getHeight()); gc = this.offImg.getGraphics(); this.thr = new Thread(this); this.thr.start(); } public void destroy() { } public void stop() { } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(this.offImg, 0, 0, this); } public void paintComp(Graphics g) { g.setColor(Color.GREEN); g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.setColor(Color.WHITE); g.fillOval(x, y, 30, 30); } public void run() { while (true) { this.paintComp(this.gc); try { if (this.posX) this.x += 3; else this.x -= 3; if (this.posY) this.y += 3; else this.y -= 3; if (x + 30 > this.getWidth()) this.posX = false; if (y + 30 > this.getHeight()) this.posY = false; if (x < 0) this.posX = true; if (y < 0) this.posY = true; Thread.sleep(25); } catch (Exception e) { } this.repaint(); } } }