Toolbar buttons similar to the procedure

  Abstract: Wizard button similar to the procedure 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="460" height="86" align="left" valign="top"> 

  JAVA prepared by the use of a similar button Wizard procedures, the preparation of documents to support the script. 

  Import java.io. *; 
  Import java.util .*; 
  Import java.awt .*; 
  Import java.awt.event .*; 

  / ** 
  * Support script file keys control procedures 
  * / 
  (Public class KeySprite 
  Public static void main (String [] args) ( 
  String filename = "test.t"; 
  Try ( 
  / / Read configuration files 
  Vector v = readFile (filename); 
  / / Implementation document 
  ParseVector (v); 

  ) Catch (IOException e) ( 
  System.out.println ( "configuration error"); 
  ) Catch (Exception e) ( 
  System.out.println ( "other errors"); 
  ) 
  ) 
  / ** 
  * Read in the paper that Vector 
  * @ Param filepath paper path 
  * / 
  Public static Vector readFile (String filepath) throws IOException ( 
  Vector v = new Vector (); 

  / / Input stream buffer documents 
  BufferedReader br = new BufferedReader ( 
  New InputStreamReader ( 
  New FileInputStream (filepath))); 
  / / Read data 
  String s = br.readLine (); 
  While (s! = Null) ( 
  / / Add to v 
  V.add (s); 
  / / Read the next line 
  S = br.readLine (); 
  ) 
  / / Off input streams 
  Br.close (); 
  / / Return data 
  Return v; 
  ) 

  / ** 
  * Read Vector Analysis, and the operation of the implementation of response 
  * @ Param v Vector object 
  * / 
  Public static void parseVector (Vector v) ( 
  Int size = v.size (); 

  Try ( 
  / / Create Robot Object 
  Robot r = new Robot (); 

  For (int i = 0; i <size; i + +) ( 
  String s = (String) v.get (i); 
  / / Decomposition 
  String [] data = s.split ( ""); 
  / / Implementation Analysis 
  If (data [0]. Equals ( "Mobile")) ( 
  / / Get coordinates 
  Int x = Integer.parseInt (data [1]); 
  Int y = Integer.parseInt (data [2]); 
  / / Mobile 
  R.mouseMove (x, y); 
  ) Else if (data [0]. Equals (the "keys")) ( 
  / / Get keys Category 
  Char c = data [1]. ToLowerCase (). CharAt (0); 
  / / Button 
  R.keyPress (c); 
  / / Release 
  R.keyRelease (c); 
  ) Else if (data [0]. Equals ( "suspended")) ( 
  / / Get suspended time 
  Int time = Integer.parseInt (data [1]); 
  / / Suspended 
  Thread.sleep (time); 
  ) 
  ) 
  ) Catch (Exception e) ( 
  E.printStackTrace (); 
  ) 
  ) 
  ) 

  </ Td> <td width="224" valign="top"> </ td> </ tr> </ table> 

  The script file test.t 

  1000 suspended 
  Mobile 200 300 
  1000 suspended 
  Mobile 210 300 
  1000 suspended 
  Mobile 220 300 
  1000 suspended 
  Mobile 230 300 
  1000 suspended 
  Mobile 240 300 
  1000 suspended 
  Mobile 250 300 
  1000 suspended 
  Mobile 260 300 
  1000 suspended 
  Mobile 270 300 
  1000 suspended 
  Mobile 280 300 
  1000 suspended 
  Mobile 290 300 
  1000 suspended 
  Mobile 300 300 
  1000 suspended 
  Mobile 310 300 

  </ Td> </ tr> <tr> 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply