home *** CD-ROM | disk | FTP | other *** search
/ Tutto per Internet / Internet.iso / soft95 / Html / qdiva / JAVA.SKL < prev    next >
Encoding:
Text File  |  1996-01-09  |  11.9 KB  |  542 lines

  1. ********************************************************
  2. **** Skeletons are pretty simple.
  3. ****
  4. **** // {{description (until it finds newline)
  5. ****   body of skeleton
  6. **** // }}
  7. ****
  8. **** Anything not bracketed by // {{ and // }} is ignored
  9. ****
  10. **** Note: There can be no spaces in the // {{ and // }} tokens.
  11. ****
  12. **** // {{{Description - start a new tree root
  13. ****
  14. **** If the body contains $SEL$, the current selection in the
  15. **** source code will be substituted.  For example:
  16. ****     <B>$SEL$$</B>
  17. **** will surround the selected text with HTML Bold tags
  18. ****
  19. **** Please send updated skeletons to : FRISKEL@INCH.COM and they
  20. **** will be available for all to use.
  21. ********************************************************
  22. //{{{Boilerplate comments
  23. //{{Long Copyright notice 
  24.  
  25. /*
  26.  *
  27.  * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
  28.  *
  29.  * Permission to use, copy, modify, and distribute this software
  30.  * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
  31.  * without fee is hereby granted. 
  32.  * 
  33.  * YOUR COMPANY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  34.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  35.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  36.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. YOUR COMPANY SHALL NOT BE LIABLE FOR
  37.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  38.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  39.  * 
  40.  * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
  41.  * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
  42.  * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
  43.  * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
  44.  * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
  45.  * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
  46.  * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES").  YOUR COMPANY
  47.  * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
  48.  * HIGH RISK ACTIVITIES.
  49.  */
  50.  
  51. //}}
  52. //{{Copyright notice, with permission
  53.  
  54. /*
  55.  *
  56.  * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
  57.  *
  58.  * Permission to use, copy, modify, and distribute this software
  59.  * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
  60.  * without fee is hereby granted. 
  61.  * 
  62.  */
  63. //}}
  64. //{{Copyright notice, without permission
  65.  
  66. /*
  67.  *
  68.  * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
  69.  *
  70.  * 
  71.  */
  72. //}}
  73. //{{Author block
  74.  
  75. /*
  76.  *
  77.  * Written By:
  78.  * Date:
  79.  * Description:
  80.  *
  81.  * Usage Notes:
  82.  *
  83.  * 
  84.  */
  85. //}}
  86. *********************************************************
  87. //{{{Program templates
  88. //{{Hello World (main program)
  89.  
  90. class HelloWord {
  91.     public static void main(String args[]) {
  92.         System.out.println("Hello World");
  93.         }
  94. }
  95.  
  96. //}}
  97. ****************
  98. //{{Hello World (Applet)
  99.  
  100. import java.applet.Applet;
  101. import java.awt.Graphics;
  102.  
  103. class HelloWorld extends Applet{
  104.     public void init() {
  105.         resize(150,25);
  106.     }
  107.     public void paint( Graphics g) {
  108.         g.drawString("Hello World",5,5);
  109.     }
  110. }
  111.  
  112. //}}
  113. //{{Runnable applet
  114. import java.awt.*;
  115. import java.applet.*;
  116.  
  117. public class MyApplet extends Applet implements Runnable
  118. {
  119.     private Thread myThread=null;
  120.     
  121.     //-------------------------------------------------
  122.     // Init
  123.     //-------------------------------------------------
  124.     public void init()
  125.     {
  126.         // ToDo: Add initialization code here
  127.     }
  128.     //-------------------------------------------------
  129.     // start
  130.     //-------------------------------------------------
  131.     public void start()
  132.     {
  133.         if (myThread == null)
  134.         {
  135.             myThread= new Thread(this);
  136.             myThread.start();
  137.         }
  138.         // Todo: Add start-up code here
  139.     }
  140.  
  141.     //-------------------------------------------------
  142.     // run
  143.     //-------------------------------------------------
  144.     public void run()
  145.     {
  146.         while(myThread != null)
  147.         {
  148.             try
  149.             {
  150.                 Thread.sleep(100);
  151.                 // Add code here
  152.             }
  153.             catch (InterruptedException e)
  154.             {
  155.             }
  156.         }
  157.         // This is called whenever a thread is created
  158.     }
  159.  
  160.     //-------------------------------------------------
  161.     // Stop
  162.     //-------------------------------------------------
  163.     public void stop()
  164.     {
  165.         myThread= null;
  166.         // Add code here
  167.     }
  168.  
  169.     //-------------------------------------------------
  170.     // Destroy
  171.     //-------------------------------------------------
  172.     public void destroy()
  173.     {
  174.         // Todo: Add clean-up code here
  175.     }
  176. }
  177.  
  178. //}}
  179. ****************************************************************
  180. //{{{Strings
  181. //{{Return the character at the specified index.
  182. charAt(int)  
  183. //}}
  184. //{{compare this String to another specified String. 
  185. compareTo(String) 
  186. //}}
  187. //{{Concatenate the specified string to the end of this String. 
  188. concat(String) 
  189. //}}
  190. //{{String that is equivalent to the specified character array. 
  191. copyValueOf(char[], int, int) 
  192. //}}
  193. //{{Get String that is equivalent to the specified character array. 
  194. copyValueOf(char[]) 
  195. //}}
  196. //{{Determines whether the String ends with some suffix. 
  197. endsWith(String) 
  198. //}}
  199. //{{Compare this String to the specified object. 
  200. equals(Object) 
  201. //}}
  202. //{{Compare without case. 
  203. equalsIgnoreCase(String) 
  204. //}}
  205. //{{Copy characters to abyte array. 
  206. getBytes(int, int, byte[], int) 
  207. //}}
  208. //{{Copy characters to a character array. 
  209. getChars(int, int, char[], int) 
  210. //}}
  211. //{{Get the hashcode for this String. 
  212. hashCode() 
  213. //}}
  214. //{{Get index of the 1st occurrence of the specified character. 
  215. indexOf(int) 
  216. //}}
  217. //{{Get String guaranteed to be from the unique String pool. 
  218. intern() 
  219. //}}
  220. //{{Gete index of the last occurrence of the specified character. 
  221. lastIndexOf(int) 
  222. //}}
  223. //{{length of the String. 
  224. length() 
  225. //}}
  226. //{{RegionMatch. 
  227. regionMatches(int, String, int, int) 
  228. regionMatches(boolean, int, String, int, int) 
  229. //}}
  230. //{{replace all occurences of oldChar with newChar. 
  231. replace(char, char) 
  232. //}}
  233. //{{Determines whether this String starts with some prefix. 
  234. startsWith(String, int) 
  235. startsWith(String) 
  236. //}} 
  237. //{{Returns the substring of this String. 
  238. substring(int) 
  239. substring(int, int) 
  240. //}}
  241. //{{Converts this String to a character array. 
  242. toCharArray() 
  243. //}}
  244. //{{Converts all of the characters in this String to lower case. 
  245. toLowerCase() 
  246. //}}
  247. //{{Converts this String to a String.
  248. toString() //Extremely useful !  But how do convert it back ?
  249. //}}
  250. //{{Convert to upper case. 
  251.  toUpperCase() 
  252. //}}
  253. //{{Trims leading and trailing whitespace from this String.  
  254. trim() 
  255. //}}
  256. //{{valueOf
  257. valueOf(Object)
  258. valueOf(char[])  
  259. valueOf(char[], int, int) 
  260. valueOf(boolean)
  261. valueOf(char)  
  262. valueOf(int)  
  263. valueOf(long)  
  264. valueOf(float)
  265. valueOf(double)  
  266. //}}
  267.  
  268. ****************
  269. //{{{program structure elements
  270. //{{switch
  271.  
  272. switch(c) {
  273. case '1':
  274.     /* put code here */
  275.     break;
  276. case '2':
  277.     /* put code here */
  278.     break;
  279. default:
  280.     /* default code */
  281. }
  282.  
  283. //}}
  284. //{{{Applet attributes
  285. //{{Set Font
  286. setFont(font = new Font("System", 12, Font.PLAIN));
  287. //}}
  288. //{{Foreground color
  289. setForeground(new Color(12615680));
  290. //}}
  291. //{{Background color
  292. setBackground(new Color(4210816));
  293. //}}
  294. //{{{Container snippets
  295. //{{add(Componet) Adds the specified component to this container.  
  296. add(Component) 
  297. //}}
  298. //{{add(String, Component) Adds the specified component to this container. 
  299. add(String, Component)
  300. //}}
  301. //{{addNotify()  Notifies the container to create a peer. 
  302. addNotify()
  303. //}}
  304. //{{countComponents()  Returns the number of components in this panel. 
  305. countComponents()
  306. //}}
  307. //{{deliverEvent(Event) Delivers an event. 
  308. deliverEvent(Event)
  309. //}}
  310. //{{getComponent(int) Gets the nth component in this container. 
  311. getComponent(int)
  312. //}}
  313. //{{getComponents() Gets all the components in this container. 
  314. getComponents()
  315. //}}
  316. //{{getLayout() Gets the layout manager for this container. 
  317. getLayout()
  318. //}}
  319. //{{insets() Returns the insets of the container. 
  320. insets()
  321. //}}
  322. //{{layout() Does a layout on this Container. 
  323. layout() 
  324. //}}
  325. //{{list(PrintStream, int) Prints out a list, starting at the specified indention, to the specified out stream. 
  326. list(PrintStream, int)
  327. //}}
  328. //{{locate(int, int) Locates the component that contains the x,y position. 
  329. locate(int, int)
  330. //}}
  331. //{{minimumSize() Returns the minimum size of this container. 
  332. minimumSize()
  333. //}}
  334. //{{paintComponents(Graphics) Paints the components in this container. 
  335. paintComponents(Graphics)
  336. //}}
  337. //{{paramString() Returns the parameter String of this Container. 
  338. paramString() 
  339. //}}
  340. //{{preferredSize() Returns the preferred size of this container. 
  341. preferredSize()
  342. //}}
  343. //{{printComponents(Graphics) Prints the components in this container. 
  344. printComponents(Graphics)
  345. //}}
  346. //{{remove(Component) Removes the specified component from this container. 
  347. remove(Component)
  348. //}}
  349. //{{removeAll() Removes all the components from this container. 
  350. removeAll()
  351. //}}
  352. //{{removeNotify() Notifies the container to remove its peer. 
  353. removeNotify()
  354. //}}
  355. //{{setLayout(LayoutManager)Sets the layout manager for this container. 
  356. setLayout(LayoutManager)
  357. //}}
  358. //{{validate() Validates this Container and all of the components contained within it. 
  359. validate()
  360. //}}
  361. SHIT
  362.         
  363. ********************************************************
  364. //{{{Network
  365. //{{Link to an URL from an applet
  366.  
  367. URL u;
  368. u = new URL("HTTP://www.inch.com/~friskel/javaside.html");
  369. getAppletContext().showDocument(u);
  370.  
  371. //}}
  372. ********************************************************
  373. //{{{Loops
  374. //{{for loop
  375.  
  376. for(i = 0; i < 10; i++ ) {
  377.     /* code here[i] */
  378. }
  379.  
  380. //}}
  381. ********************************************************
  382. //{{while loop
  383.  
  384. int i = 0; 
  385. while(i < 10) {
  386.     /* code here[i] */
  387.     ++i;
  388. }
  389.  
  390. //}}
  391.  
  392. //{{{Events
  393. //{{Mouse
  394. public boolean handleEvent(Event evt)
  395.     {
  396.         switch(evt.id)
  397.         {
  398.             case Event.MOUSE_DOWN:
  399.             {
  400.                 // Add event handling code here
  401.                 return true;
  402.             }
  403.             case Event.MOUSE_DRAG:
  404.             {
  405.                 // Add event handling code here
  406.                 return true;
  407.             }
  408.             case Event.MOUSE_ENTER:
  409.             {
  410.                 // Add event handling code here
  411.                 return true;
  412.             }
  413.             case Event.MOUSE_EXIT:
  414.             {
  415.                 // Add event handling code here
  416.                 return true;
  417.             }
  418.             case Event.MOUSE_MOVE:
  419.             {
  420.                 // Add event handling code here
  421.                 return true;
  422.             }
  423.             case Event.MOUSE_UP:
  424.             {
  425.                 // Add event handling code here
  426.                 return true;
  427.             }
  428.             default:
  429.             return false;
  430.         }
  431.     }
  432.  
  433. //}}
  434. //{{Keyboard
  435. switch(evt.id)
  436.         {
  437.             case Event.KEY_ACTION:
  438.             {
  439.                 // Add event handling code here
  440.                 return true;
  441.             }
  442.             case Event.KEY_ACTION_RELEASE:
  443.             {
  444.                 // Add event handling code here
  445.                 return true;
  446.             }
  447.             case Event.KEY_PRESS:
  448.             {
  449.                 // Add event handling code here
  450.                 return true;
  451.             }
  452.             case Event.KEY_RELEASE:
  453.             {
  454.                 // Add event handling code here
  455.                 return true;
  456.             }
  457.             default:
  458.             return false;
  459.         }
  460. //}}
  461. //{{Focus
  462. public boolean handleEvent(Event evt)
  463.     {
  464.         switch(evt.id)
  465.         {
  466.             case Event.GOT_FOCUS:
  467.             {
  468.                 // Add event handling code here
  469.                 return true;
  470.             }
  471.             case Event.LOST_FOCUS:
  472.             {
  473.                 // Add event handling code here
  474.                 return true;
  475.             }
  476.             default:
  477.             return false;
  478.         }
  479.     }
  480. //}}
  481. //{{{Awt Container Overrides
  482. //{{update(Graphics g)
  483.     public void update(Graphics g)
  484.     {
  485.     }
  486. //}}
  487. //{{keyDown
  488.     public void keyDown(Event evt, int key)
  489.     {
  490.      
  491.     }
  492. //}}
  493. //{{mouseDown
  494.     public void mouseDown(Event evt, int x, int y)
  495.     {
  496.     }
  497. //}}
  498. //{{mouseDrag
  499.     public void mouseDrag(Event evt, int x, int y)
  500.     {
  501.     }
  502. //}}
  503. //{{mouseEnter
  504.     public void mouseEnter(Event evt, int x, int y)
  505.     {
  506.     }
  507. //}}
  508. //{{mouseExit
  509.     public void mouseExit(Event evt, int x, int y)
  510.     {
  511.     }
  512. //}}
  513. //{{mouseMove
  514.     public void mouseMove(Event evt, int x, int y)
  515.     {
  516.     }
  517. //}}
  518. //{{mouseUp
  519.     public void mouseUp()
  520.     {
  521.     }
  522. //}}
  523. //{{gotFocus
  524.     public void gotFocus()
  525.     {
  526.     }
  527. //}}
  528. //{{lostFocus
  529.     public void lostFocus()
  530.     {
  531.     }
  532. //}}
  533. //{{{exceptions
  534. //{{UnknownHost
  535. try 
  536. {
  537.     hostName = getHostByAddr(address);
  538. } catch (UnknownHostException e) 
  539. {
  540.     //Catch here
  541. }
  542. //}}