JSP page invoke applet to realize the capitalization conversion of RMB (II.)

Source: Internet
Author: User
Tags getcolor integer
js| Case | rmb | page | conversion

Appendix

1. Applet code:

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= "Input error:" +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= "Input error:" +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 package, Welcome to Lqhboy@163.com




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.