Created
November 5, 2011 06:13
-
-
Save tetsurokitahara/1341174 to your computer and use it in GitHub Desktop.
手抜きお絵描きプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
/** 手抜きお絵描きプログラム. | |
こちらも全くGroovyっぽくありませんが・・・. | |
(C言語経験者向けのサンプルとして作ったので.) */ | |
class PaintFrame extends JFrame { | |
int[] xx = new int[1000000]; | |
int[] yy = new int[1000000]; | |
int n = 0; | |
PaintFrame() { | |
setSize(640, 480); | |
mouseDragged = { e -> | |
xx[n] = e.getX(); | |
yy[n] = e.getY(); | |
n++; | |
repaint(); | |
}; | |
} | |
void paint(Graphics g) { | |
super.paint(g); | |
int i; | |
for (i = 0; i < n; i++) { | |
g.fillOval(xx[i], yy[i], 16, 16); | |
} | |
} | |
} | |
static void main(String[] args) { | |
PaintFrame f = new PaintFrame(); | |
f.setVisible(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment