home *** CD-ROM | disk | FTP | other *** search
- ********************************************************
- **** Skeletons are pretty simple.
- ****
- **** // {{description (until it finds newline)
- **** body of skeleton
- **** // }}
- ****
- **** Anything not bracketed by // {{ and // }} is ignored
- ****
- **** Note: There can be no spaces in the // {{ and // }} tokens.
- ****
- **** // {{{Description - start a new tree root
- ****
- **** If the body contains $SEL$, the current selection in the
- **** source code will be substituted. For example:
- **** <B>$SEL$$</B>
- **** will surround the selected text with HTML Bold tags
- ****
- **** Please send updated skeletons to : FRISKEL@INCH.COM and they
- **** will be available for all to use.
- ********************************************************
- //{{{Boilerplate comments
- //{{Long Copyright notice
-
- /*
- *
- * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
- * without fee is hereby granted.
- *
- * YOUR COMPANY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. YOUR COMPANY SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- *
- * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
- * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
- * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
- * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
- * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
- * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
- * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). YOUR COMPANY
- * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
- * HIGH RISK ACTIVITIES.
- */
-
- //}}
- //{{Copyright notice, with permission
-
- /*
- *
- * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
- * without fee is hereby granted.
- *
- */
- //}}
- //{{Copyright notice, without permission
-
- /*
- *
- * Copyright (c) 1996 Your Company, Inc. All Rights Reserved.
- *
- *
- */
- //}}
- //{{Author block
-
- /*
- *
- * Written By:
- * Date:
- * Description:
- *
- * Usage Notes:
- *
- *
- */
- //}}
- *********************************************************
- //{{{Program templates
- //{{Hello World (main program)
-
- class HelloWord {
- public static void main(String args[]) {
- System.out.println("Hello World");
- }
- }
-
- //}}
- ****************
- //{{Hello World (Applet)
-
- import java.applet.Applet;
- import java.awt.Graphics;
-
- class HelloWorld extends Applet{
- public void init() {
- resize(150,25);
- }
- public void paint( Graphics g) {
- g.drawString("Hello World",5,5);
- }
- }
-
- //}}
- //{{Runnable applet
- import java.awt.*;
- import java.applet.*;
-
- public class MyApplet extends Applet implements Runnable
- {
- private Thread myThread=null;
-
- //-------------------------------------------------
- // Init
- //-------------------------------------------------
- public void init()
- {
- // ToDo: Add initialization code here
- }
- //-------------------------------------------------
- // start
- //-------------------------------------------------
- public void start()
- {
- if (myThread == null)
- {
- myThread= new Thread(this);
- myThread.start();
- }
- // Todo: Add start-up code here
- }
-
- //-------------------------------------------------
- // run
- //-------------------------------------------------
- public void run()
- {
- while(myThread != null)
- {
- try
- {
- Thread.sleep(100);
- // Add code here
- }
- catch (InterruptedException e)
- {
- }
- }
- // This is called whenever a thread is created
- }
-
- //-------------------------------------------------
- // Stop
- //-------------------------------------------------
- public void stop()
- {
- myThread= null;
- // Add code here
- }
-
- //-------------------------------------------------
- // Destroy
- //-------------------------------------------------
- public void destroy()
- {
- // Todo: Add clean-up code here
- }
- }
-
- //}}
- ****************************************************************
- //{{{Strings
- //{{Return the character at the specified index.
- charAt(int)
- //}}
- //{{compare this String to another specified String.
- compareTo(String)
- //}}
- //{{Concatenate the specified string to the end of this String.
- concat(String)
- //}}
- //{{String that is equivalent to the specified character array.
- copyValueOf(char[], int, int)
- //}}
- //{{Get String that is equivalent to the specified character array.
- copyValueOf(char[])
- //}}
- //{{Determines whether the String ends with some suffix.
- endsWith(String)
- //}}
- //{{Compare this String to the specified object.
- equals(Object)
- //}}
- //{{Compare without case.
- equalsIgnoreCase(String)
- //}}
- //{{Copy characters to abyte array.
- getBytes(int, int, byte[], int)
- //}}
- //{{Copy characters to a character array.
- getChars(int, int, char[], int)
- //}}
- //{{Get the hashcode for this String.
- hashCode()
- //}}
- //{{Get index of the 1st occurrence of the specified character.
- indexOf(int)
- //}}
- //{{Get String guaranteed to be from the unique String pool.
- intern()
- //}}
- //{{Gete index of the last occurrence of the specified character.
- lastIndexOf(int)
- //}}
- //{{length of the String.
- length()
- //}}
- //{{RegionMatch.
- regionMatches(int, String, int, int)
- regionMatches(boolean, int, String, int, int)
- //}}
- //{{replace all occurences of oldChar with newChar.
- replace(char, char)
- //}}
- //{{Determines whether this String starts with some prefix.
- startsWith(String, int)
- startsWith(String)
- //}}
- //{{Returns the substring of this String.
- substring(int)
- substring(int, int)
- //}}
- //{{Converts this String to a character array.
- toCharArray()
- //}}
- //{{Converts all of the characters in this String to lower case.
- toLowerCase()
- //}}
- //{{Converts this String to a String.
- toString() //Extremely useful ! But how do convert it back ?
- //}}
- //{{Convert to upper case.
- toUpperCase()
- //}}
- //{{Trims leading and trailing whitespace from this String.
- trim()
- //}}
- //{{valueOf
- valueOf(Object)
- valueOf(char[])
- valueOf(char[], int, int)
- valueOf(boolean)
- valueOf(char)
- valueOf(int)
- valueOf(long)
- valueOf(float)
- valueOf(double)
- //}}
-
- ****************
- //{{{program structure elements
- //{{switch
-
- switch(c) {
- case '1':
- /* put code here */
- break;
- case '2':
- /* put code here */
- break;
- default:
- /* default code */
- }
-
- //}}
- //{{{Applet attributes
- //{{Set Font
- setFont(font = new Font("System", 12, Font.PLAIN));
- //}}
- //{{Foreground color
- setForeground(new Color(12615680));
- //}}
- //{{Background color
- setBackground(new Color(4210816));
- //}}
- //{{{Container snippets
- //{{add(Componet) Adds the specified component to this container.
- add(Component)
- //}}
- //{{add(String, Component) Adds the specified component to this container.
- add(String, Component)
- //}}
- //{{addNotify() Notifies the container to create a peer.
- addNotify()
- //}}
- //{{countComponents() Returns the number of components in this panel.
- countComponents()
- //}}
- //{{deliverEvent(Event) Delivers an event.
- deliverEvent(Event)
- //}}
- //{{getComponent(int) Gets the nth component in this container.
- getComponent(int)
- //}}
- //{{getComponents() Gets all the components in this container.
- getComponents()
- //}}
- //{{getLayout() Gets the layout manager for this container.
- getLayout()
- //}}
- //{{insets() Returns the insets of the container.
- insets()
- //}}
- //{{layout() Does a layout on this Container.
- layout()
- //}}
- //{{list(PrintStream, int) Prints out a list, starting at the specified indention, to the specified out stream.
- list(PrintStream, int)
- //}}
- //{{locate(int, int) Locates the component that contains the x,y position.
- locate(int, int)
- //}}
- //{{minimumSize() Returns the minimum size of this container.
- minimumSize()
- //}}
- //{{paintComponents(Graphics) Paints the components in this container.
- paintComponents(Graphics)
- //}}
- //{{paramString() Returns the parameter String of this Container.
- paramString()
- //}}
- //{{preferredSize() Returns the preferred size of this container.
- preferredSize()
- //}}
- //{{printComponents(Graphics) Prints the components in this container.
- printComponents(Graphics)
- //}}
- //{{remove(Component) Removes the specified component from this container.
- remove(Component)
- //}}
- //{{removeAll() Removes all the components from this container.
- removeAll()
- //}}
- //{{removeNotify() Notifies the container to remove its peer.
- removeNotify()
- //}}
- //{{setLayout(LayoutManager)Sets the layout manager for this container.
- setLayout(LayoutManager)
- //}}
- //{{validate() Validates this Container and all of the components contained within it.
- validate()
- //}}
- SHIT
-
- ********************************************************
- //{{{Network
- //{{Link to an URL from an applet
-
- URL u;
- u = new URL("HTTP://www.inch.com/~friskel/javaside.html");
- getAppletContext().showDocument(u);
-
- //}}
- ********************************************************
- //{{{Loops
- //{{for loop
-
- for(i = 0; i < 10; i++ ) {
- /* code here[i] */
- }
-
- //}}
- ********************************************************
- //{{while loop
-
- int i = 0;
- while(i < 10) {
- /* code here[i] */
- ++i;
- }
-
- //}}
-
- //{{{Events
- //{{Mouse
- public boolean handleEvent(Event evt)
- {
- switch(evt.id)
- {
- case Event.MOUSE_DOWN:
- {
- // Add event handling code here
- return true;
- }
- case Event.MOUSE_DRAG:
- {
- // Add event handling code here
- return true;
- }
- case Event.MOUSE_ENTER:
- {
- // Add event handling code here
- return true;
- }
- case Event.MOUSE_EXIT:
- {
- // Add event handling code here
- return true;
- }
- case Event.MOUSE_MOVE:
- {
- // Add event handling code here
- return true;
- }
- case Event.MOUSE_UP:
- {
- // Add event handling code here
- return true;
- }
- default:
- return false;
- }
- }
-
- //}}
- //{{Keyboard
- switch(evt.id)
- {
- case Event.KEY_ACTION:
- {
- // Add event handling code here
- return true;
- }
- case Event.KEY_ACTION_RELEASE:
- {
- // Add event handling code here
- return true;
- }
- case Event.KEY_PRESS:
- {
- // Add event handling code here
- return true;
- }
- case Event.KEY_RELEASE:
- {
- // Add event handling code here
- return true;
- }
- default:
- return false;
- }
- //}}
- //{{Focus
- public boolean handleEvent(Event evt)
- {
- switch(evt.id)
- {
- case Event.GOT_FOCUS:
- {
- // Add event handling code here
- return true;
- }
- case Event.LOST_FOCUS:
- {
- // Add event handling code here
- return true;
- }
- default:
- return false;
- }
- }
- //}}
- //{{{Awt Container Overrides
- //{{update(Graphics g)
- public void update(Graphics g)
- {
- }
- //}}
- //{{keyDown
- public void keyDown(Event evt, int key)
- {
-
- }
- //}}
- //{{mouseDown
- public void mouseDown(Event evt, int x, int y)
- {
- }
- //}}
- //{{mouseDrag
- public void mouseDrag(Event evt, int x, int y)
- {
- }
- //}}
- //{{mouseEnter
- public void mouseEnter(Event evt, int x, int y)
- {
- }
- //}}
- //{{mouseExit
- public void mouseExit(Event evt, int x, int y)
- {
- }
- //}}
- //{{mouseMove
- public void mouseMove(Event evt, int x, int y)
- {
- }
- //}}
- //{{mouseUp
- public void mouseUp()
- {
- }
- //}}
- //{{gotFocus
- public void gotFocus()
- {
- }
- //}}
- //{{lostFocus
- public void lostFocus()
- {
- }
- //}}
- //{{{exceptions
- //{{UnknownHost
- try
- {
- hostName = getHostByAddr(address);
- } catch (UnknownHostException e)
- {
- //Catch here
- }
- //}}