Here you can find the source of drawBubbles(Graphics g, int nCode)
public static void drawBubbles(Graphics g, int nCode)
//package com.java2s; //License from project: LGPL import java.awt.Color; import java.awt.Graphics; import java.util.Random; public class Main { public static void drawBubbles(Graphics g, int nCode) { int width = g.getClipBounds().width; int height = g.getClipBounds().height; g.setColor(Color.BLUE);//from w ww. j ava 2s .c o m g.fillRect(1, 1, width - 2, height - 2); Random r = new Random(nCode); int nBubbles = r.nextInt(3) + 2; for (int i = 0; i < nBubbles; i++) { int xB = (int) (r.nextDouble() * width); int yB = (int) (r.nextDouble() * height); int rB = (int) (r.nextDouble() * Math.min(width, height) / 5.0); g.setColor(Color.CYAN); g.drawOval(xB - rB, yB - rB, rB * 2, rB * 2); } } }