Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tetsurokitahara
Created November 5, 2011 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tetsurokitahara/1341174 to your computer and use it in GitHub Desktop.
Save tetsurokitahara/1341174 to your computer and use it in GitHub Desktop.
手抜きお絵描きプログラム
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