快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

产生彩色验证码_(javabean实现)

本文将教你如何一步一步地使用javabean实现了产生彩色验证码的全过程,并提供源代码。


 文件名:Image.java
=====================================
/*
 * Created on 2004-8-4
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package myclass.test;

import java.awt.*;
import java.awt.image.*;
import java.util.*;

/**
 * @author
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class Image {
 
  public String sRand=\"\";
 
  public Color getRandColor(int fc,int bc){//给定范围获得随机颜色
   Random random = new Random();
   if(fc>255) fc=255;
   if(bc>255) bc=255;
   int r=fc+random.nextInt(bc-fc);
   int g=fc+random.nextInt(bc-fc);
   int b=fc+random.nextInt(bc-fc);
   return new Color(r,g,b);
   }
  public BufferedImage creatImage(){

 // 在内存中创建图象
    int width=60, height=20;
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    // 获取图形上下文
    Graphics g = image.getGraphics();

    //生成随机类
    Random random = new Random();

    // 设定背景色
    g.setColor(getRandColor(200,250));
    g.fillRect(0, 0, width, height);

    //设定字体
    g.setFont(new Font(\"Times New Roman\",Font.PLAIN,18));





返回类别: 教程
上一教程: 数据库连接池Java实现小结
下一教程: 从报表的绘制方法来谈谈:SQL报表,Cell报表和中国式报表.

您可以阅读与"产生彩色验证码_(javabean实现)"相关的教程:
· 产生彩色验证码_(javabean实现)
· 产生彩色验证码_(JAVABEAN实现)
· JSP彩色验证码
· JSP生成彩色验证码程序
· 随机验证码的实现思路
    微笑服务 优质保证 索取样品