动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   Jsp → 阅读文章

 jsp页面调用applet实现人民币的大小写转换 (二)

作者来源: 
阅读 1509 人次 , 2006-3-29 4:23:00 

附录

1applet代码:

 

package lqh.rmb.applicate;

 

import java.awt.*;

import java.awt.event.*;

import java.applet.*;

import lqh.rmb.*;

 

public class rmb extends applet {

  private boolean isstandalone = false;

  private rmbconversion rmb=new rmbconversion();

  private  string var0 = "";

  private  string re_rmb="";

  private  string wigth ="0";

  private string back_color;

  private string fore_color;

 

  public string getparameter(string key, string def) {

return isstandalone ? system.getproperty(key, def) :

(getparameter(key) != null ? getparameter(key) : def);

  }

  public void paint(graphics g) {

  if(wigth.equals("0")){

  wigth = "560";

  }

  int i= integer.parseint(wigth);

 

  if(checknum(var0)){

  if(var0.endswith(".")){

var0 = var0.substring(0,var0.length()-1);

  }

  re_rmb= rmb.rmb(var0);

  }else{

  re_rmb="输入错误"+var0;

  }

  int middel =(i - re_rmb.length()*12)/2;

  this.setbackground(new color(getcolor(back_color)[0], getcolor(back_color)[1], getcolor(back_color)[2]));

  this.setforeground(new color(getcolor(fore_color)[0], getcolor(fore_color)[1], getcolor(fore_color)[2]));

  g.drawstring(re_rmb,middel,20);

  }

  public void init() {

  try {

  back_color = this.getparameter("rgb_back", "241|247|251");

}catch(exception e) {e.printstacktrace();}

try {

fore_color = this.getparameter("rgb_fore", "255|0|0");

}catch(exception e) {e.printstacktrace();}

try {

wigth = this.getparameter("wigth", "0");

}catch(exception e) {e.printstacktrace();}

try {

jbinit();

}catch(exception e) { e.printstacktrace(); }

 }

  private void jbinit() throws exception {

this.setbackground(new color(getcolor(back_color)[0], getcolor(back_color)[1], getcolor(back_color)[2]));

  }

  public void setrmb(string rmb_temp){

  var0 = rmb_temp;

  }

  public string getrmb(string rmb_temp){

  if(checknum(rmb_temp)){

  if(rmb_temp.endswith(".")){

rmb_temp = rmb_temp.substring(0,rmb_temp.length()-1);

  }

  re_rmb= rmb.rmb(rmb_temp);

  }else{

  re_rmb="输入错误"+rmb_temp;

  }

  return re_rmb;

  }

  public boolean checknum(string str){

  string numchar="0123456789.";

  boolean breakboolean = false;

  for(int i=0;i<str.length();i++){

  if(numchar.indexof(str.substring(i,i+1))<0){

  breakboolean =true;

  }

  if(breakboolean) break;

  }

  if(breakboolean){

  return false;

  }else{

  if(str.startswith(".")){

  return false;

  }else{

  return true;

  }

  }

  }

  public string[][] getparameterinfo() {

  string[][] pinfo =

  {

  {"rgb_back", "string", ""},

  {"rgb_fore", "string", ""},

  {"wigth",   "string", ""},

  };

  return pinfo;

  }

  private int[] getcolor(string rgb){

int[] rgb_return = new int[3];

int index =0,nextindex=0,len=0;

while((index =rgb.indexof("|",nextindex))>-1){

  rgb_return[len]=getint(rgb.substring(nextindex,index));

  nextindex=index+1;

  len++;

}

rgb_return[len]=getint(rgb.substring(nextindex));

return rgb_return;

  }

  private int getint(string str){

  try{

  return integer.parseint(str);

  }catch(exception e){

  return 0;

  }

  }

}

2.java包,欢迎索取lqhboy@163.com

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:用缓冲技术提高JSP应用的性能和稳定性
· 下一篇:jsp页面调用applet实现人民币的大小写转换 (一)
· Freebsd+Resin成功建立支持jsp平台
· MySQL翻页例子
· 利用JSP 2.0开发Web应用程序
· java在Linux下的web应用(一)
· Servlets和JSP Pages最佳实践


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077