とりあえず。
public class RandomPoint extends JComponent{
@Override
protected void paintComponent(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, 400, 350);
g.setColor(Color.BLACK);
for(int i = 0; i < xs.size(); ++i){
g.drawOval(100 + xs.get(i), 30 + ys.get(i), 3, 3);
}
}
static List<Integer> xs = new ArrayList<Integer>();
static List<Integer> ys = new ArrayList<Integer>();
public static void main(String[] args){
int x = 0;
int y = 0;
final int n = 20;
final int width = 200;
final int r = width / n * 2 - 1;
for(int i = 0; i < n; ++i){
x+= Math.random() * r + 1;
xs.add(x);
y += Math.random() * r + 1;
ys.add(y);
}
Collections.shuffle(xs);
Collections.shuffle(ys);
JFrame f = new JFrame("ランダムな点");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new RandomPoint());
f.setSize(400, 300);
f.setVisible(true);
}
}