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
- Bootstrap
- 안드로이드
- MANTIS
- jsp
- C#
- 이클립스
- TextBox
- STS
- MSsql
- varags
- Apache Lucene
- Android
- 웹 서비스
- 자바
- Java
- Eclipse
- WebView
- asp.net
- Redirect
- scrollView
- javascript
- MS-SQL
- SpringSource Tool Suite
- Web Service
- 컬럼명
- 자바스크립트
- Maven
- html
- decompiler
- 웹뷰
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(); } } }