网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>JAVA>>新手入门>>基础入门>查看文档  
  如何用java编写一个扫描仪程序     
  文章作者:未知  文章来源:水木森林  
  查看:87次  录入:管理员--2007-11-17  
 
  javatwain may be a powerful solution,you can go to www.gnome.sk to download the newest package.
   javatwain version 5.1 is a part of the morena 6.0 framework now.
  
   below is an simple example:
   /*
   * $id: exampleshow.java,v 1.5 2002/07/15 13:48:55 mmotovsk exp $
   *
   * copyright (c) 1999-2002 gnome spol. s r.o. all rights reserved.
   *
   * this software is the confidential and proprietary information of
   * gnome spol. s r.o. you shall not disclose such confidential
   * information and shall use it only in accordance with the terms
   * of the license agreement you entered into with gnome.
   */
  
  // javatwain package version 5.1
  
  /**
   exampleshow demonstrates how to scan an image using defaults
   from the twain source. <br>
  */
  
  import java.awt.*;
  import java.awt.event.*;
  import sk.gnome.twain.*;
  
  public class exampleshow extends frame
  { image image;
   public void paint(graphics g) 
   { if (null!=image)
     g.drawimage(image, 0, 0, this);
   }
   
   windowlistener windowadapter=new windowadapter()
   { public void windowclosing(windowevent e)
    { system.exit(0);
    }
   };
   
   public exampleshow()
   { try
    { addwindowlistener(windowadapter);
     settitle("exampleshow frame application");
     // open twain select source dialog box
     // and initialize the source selected by the user.
     twainsource source=twainmanager.selectsource(null);
     image=toolkit.getdefaulttoolkit().createimage(source);
     // wait for the image to be completed
     mediatracker tracker=new mediatracker(this);
     tracker.addimage(image, 0);
     // this is the moment the scanner user interface pops up
     system.err.println("start loading image ...");
     try
     { tracker.waitforall();
     }
     catch (interruptedexception e)
     { system.err.println("image loading was interrupted!");
      e.printstacktrace();
     }
     tracker.removeimage(image);
     system.err.println("image loaded ...");
     setsize(image.getwidth(this), image.getheight(this));
     setvisible(true);
     twainmanager.close();
    }
    catch (twainexception e)
    { e.printstacktrace();
    }
   }
   
   public static void main(string[] args)
   { new exampleshow();
   }
  }
 
 
上一篇: .net下调用sqlserver2000中存储过程    下一篇: ibm关于数据验证和异常处理的一些文章
  相关文档
基于jdk5.0的一些collection类的使用总结 11-17
精通hibernate之映射继承关系二(图) 11-17
基于jdk5.0的一些collection类使用总结 03-05
hibernate获得成功的十大理由 11-17
面向方面编程慨述和jboss 11-17
java初学者实践教程22-输入/输出 11-17
javascript+xml实现二级下拉菜单二 11-17
java进阶:jni使用技巧点滴积累 11-17
j2ee基础:企业级javabeans tm技术介绍 11-16
为什么很多java开发人员对jcp感觉失望 01-28
j2me移动2d图形开发快速入门 11-16
情人碰面的问题.java代码 11-17
java指南之使用图形:解决常见图像问题 11-17
java游戏开发案例-方块游戏 11-17
用java实现股票走势图 11-17
eclipse插件管理小结 11-17
用xml和servlet构建在线问答系统 11-17
让java程序自带jre运行 11-17
mashups+ajax打造全新web开发 11-17
java高级:讨论ajax之所以优于jsf的原因 11-16
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
技术电话:13616026886
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息