Package tk. donghongyujava. util; import java. awt. color; public class RandomImage {private final static int WIDTH = 100; private final static int HEIGHT = 30; public static Random rd = new Random (); public static BufferedImage creatImage () {// draw the image BufferedImage image = new BufferedImage (WIDTH, HEIGHT, BufferedImage. TYPE_INT_BGR); // obtain the paint brush Graphics g = image. getGraphics (); // set the background drawBackground (g); // draw the border drawBorder (g); // draw the content drawContent (g); // draw the interference drawDisturb (g ); return image;} private static void drawContent (Graphics g) {// TODO Auto-generated method stubString con = "inline"; StringBuffer sb = new StringBuffer (); for (int I = 0; I <4; I ++) {int index = rd. nextInt (con. length (); char str = con. charAt (index); sb. append (str + "");} g. setColor (Color. black); g. setFont (new Font ("Gungsuh", Font. BOLD, 20); g. drawString (sb. toString (), 15, 20);} private static void drawDisturb (Graphics g) {// TODO Auto-generated method stubg. setColor (Color. BLUE); for (int I = 0; I <4; I ++) {int x1 = rd. nextInt (WIDTH); int y1 = rd. nextInt (HEIGHT); int x2 = rd. nextInt (WIDTH); int y2 = rd. nextInt (HEIGHT); g. drawLine (x1, y1, x2, y2);} g. setColor (Color. red); g. drawOval (30, 20, 2, 2);} private static void drawBorder (Graphics g) {// TODO Auto-generated method stubg. setColor (Color. yellow); g. drawRect (0, 0, WIDTH-2, HEIGHT-2);} private static void drawBackground (Graphics g) {// TODO Auto-generated method stubg. setColor (Color. green); g. fillRect (0, 0, WIDTH, HEIGHT );}}