Search result for 'java case example menu'
(0.0686659812927 seconds)
9 pages : 1 2 3 4 5 6 7 8 9 Next › Last»

variable3/Option Menu Example ( Java)

//MainActivity.java
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {

		case R.id.list_users:
			Intent a = new Intent(HomeActivity.this, ListsUsersActivity.class);
			startActivity(a);
			break;
		case R.id.add_city:
			Intent b = new Intent(this, AddCityActivity.class);
			startActivity(b);
			break;
		case R.id.exit:
			Intent c = new Intent(this, HomeActivity.class);
			startActivity(c);
			break;
		}

		return true;
	}
//menu.xml<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
	<item android:id="@+id/list_users" android:title="List Users" />
	<item android:id="@+id/add_city" android:title="Add City" />
	<item android:id="@+id/exit" android:title="Exit" />
</menu>

remysharp/String.toCamelCase ( JavaScript)

String.prototype.toCamelCase = function() {
  return this.toString()
    .replace(/([A-Z]+)/g, function(m,l){
      return l.substr(0,1).toUpperCase() + l.toLowerCase().substr(1,l.length);
    })
    .replace(/[\-_\s](.)/g, function(m, l){
      return l.toUpperCase();
    });
};

"example_one".toCamelCase(); // => exampleOne "Example-Two".toCamelCase(); // => ExampleTwo "example-Three".toLowerCase().toCamelCase(); // => exampleTwo

// execption: BestPCCode => BestPccode

William_Wilson/Drop down (overlapping) menu ( JavaScript)

function ShowPanel()
{
     if (document.getElementById('panel').style.display == 'block')
     {
          document.getElementById('panel').style.display = 'none';
          document.getElementById('up_down').src = "./down.gif";
     }
     else
     {
          document.getElementById('panel').style.display = 'block';
          document.getElementById('up_down').src = "./up.gif";
     }
}






//Example HTML:
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html&gt;
&lt;head&gt;
     &lt;link rel="stylesheet" type="text/css" href="./style.css"&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script language="Javascript"&gt;
&lt;!--

     function ShowPanel()
     {
          if (document.getElementById('panel').style.display == 'block')
          {
               document.getElementById('panel').style.display = 'none';
               document.getElementById('up_down').src = "./down.gif";
          }
          else
          {
               document.getElementById('panel').style.display = 'block';
               document.getElementById('up_down').src = "./up.gif";
          }
     }
//--&gt;
&lt;/script&gt;

&lt;div id="menu_title"&gt;

&lt;menu_head&gt;
     &lt;!-- (title bar) - defines width of menu //--&gt;
&lt;/meun_head&gt;
&lt;table&gt;
     &lt;tr&gt;
          &lt;td width="150"&gt;
               &lt;b&gt;Drop Down Menu Title&lt;/b&gt;
          &lt;/td&gt;
          &lt;td&gt;
               &lt;a href="#" onclick="ShowPanel();"&gt;
                    &lt;img id="up_down" src="./down.gif" alt="V"&gt;
               &lt;/a&gt;
          &lt;/td&gt;
     &lt;/tr&gt;
&lt;/table&gt;

&lt;menu_body&gt;
     &lt;!-- (items displayed on drop down) //--&gt;
&lt;/menu_body&gt;
&lt;div id="panel"&gt;
&lt;hr&gt;

     &lt;a href="http://www.google.com"&gt;Google&lt;/a&gt;
     &lt;br&gt;
     &lt;a href="http://www.dreamincode.net"&gt;Dream In Code&lt;/a&gt;&lt;br&gt;

&lt;hr&gt;

&lt;table&gt;
     &lt;form action="?" method="post"&gt;&lt;/form&gt;
     &lt;tr&gt;
          &lt;td&gt;User Name:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;
               &lt;input type = "text" class="input_text" name="username" id="username" value=""&gt;
          &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;Password:&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td&gt;
               &lt;input type="password" class="input_text" name="password" id="password" value=""&gt;
          &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
          &lt;td align="right" height="25" valign="top"&gt;
               &lt;input type="submit" class="button" value="Login"&gt;
          &lt;/td&gt;
     &lt;/tr&gt;

&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;



//script.css:
a img
{
     border: 0;
     padding-top: 2px;
     padding-right: 2px;
}

a:active
{
     padding-left: 5px;
     color: #000000;
}

a:link
{
     padding-left: 5px;
     color: #000000;
}

a:visited
{
     padding-left: 5px;
     color: #000000;
}

body
{
     font: 9pt Arial, Verdana, Sans-Serif;
     background: #FFFFFF;
     color: #000000;
}

.button
{
     margin-top: 5px;
}

hr
{
     max-height: 1px;
     height: 1px;
     color: #000000;
     border-style: solid;
}

input
{
     border: 1px solid #00009E;
     font-size: 10px;
     font-family: Verdana;
}

.input_text
{
     background-color: #FFFF94;
     vertical-align: middle;
     width: 138px;
}

#menu_title
{
     width: 150px;
     height: 25px;
     background-color: #FBA000;
     opacity: 0.8;
     -moz-opacity: 0.8;
     filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80);
     position: fixed;
     top:  0px;
     left: 0px;
     margin-top:  5px;
     margin-left: 5px;
     padding: 2px;
}

#panel
{
     display: none;
     position: fixed;
     top: 28px;
     background-color: #FBA000;
     width: 150px;
     margin-left: 5px;
     left: 0px;
     margin-top: 0px;
     padding: 2px;
}

#panel a
{
     text-decoration:none;
     font-weight:bold;
     line-height:150%;
}

table
{
     border: none;
     padding: 0;
     spacing: 0;
}

Create a menu with the same style as the "Member Panel" on DIC. (Example including Javascript, CSS and HTML)

jerryvig/Gov Auctions 15 ( Java)

package com.mktneutral;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.HttpURLConnection;
import java.net.URLEncoder;
import java.io.OutputStreamWriter;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.OutputStream;
import java.util.regex.Pattern;
import org.htmlparser.Parser;
import org.htmlparser.Node;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

public class GovAuctions {
    private static String searchString;
    private static String responseData; 
    private static Connection hsql;
    private static Statement stmt;
    private static String searchState;
    private static HashMap<String,String> stateMap;

    public static void main( String[] args ) {
	String resp = runScrapers("ford",15,"ALL");
	System.out.println( resp );        
    }

    public static String runScrapers( String _searchString, int searchEngineInt, String _searchState ) { 
	try {
	   Class.forName("org.hsqldb.jdbcDriver");
	} catch ( ClassNotFoundException cnfe ) { cnfe.printStackTrace(); }
   
        String[] stateNameList = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", "American Samoa", "Guam", "Northern Mariana Islands", "Puerto Rico" };
        String[] stateAbbrevList = { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY", "AS", "GU", "MP", "PR" };
          
        stateMap = new HashMap<String,String>();
        for ( int i=0; i<stateNameList.length; i++ ) {
	   stateMap.put( stateAbbrevList[i], stateNameList[i] );
        }

	hsql = null;
	try {
	   hsql = DriverManager.getConnection( "jdbc:hsqldb:file:govauctionsdb", "SA", "" );
	}
	catch ( SQLException sqle ) { sqle.printStackTrace(); }

	try {
	    stmt = hsql.createStatement();
	    stmt.executeUpdate( "DROP TABLE IF EXISTS auction_records" );
	    stmt.executeUpdate( "CREATE TABLE auction_records ( website VARCHAR(64), url VARCHAR(1024), results_content VARCHAR(1536) )" );
	} catch ( SQLException sqle ) { sqle.printStackTrace(); }

	searchState = _searchState;
	searchString = _searchString;

	responseData = "";

	if ( searchEngineInt == 0 ) {
	    GovLiquidation();  
	}
	if ( searchEngineInt == 1 ) {
	    GSAAuctions();
	}
	if ( searchEngineInt == 2 ) {
	    IRSAuctions(); 
	}
	if ( searchEngineInt == 3 ) {
	    BidCorp();
	}
	if ( searchEngineInt == 4 ) {
	    bid4Assets();
	}
       	if ( searchEngineInt == 5 ) {
	    BankruptcySales();
	}
       	if ( searchEngineInt == 6 ) {
	    PublicSurplus();
	}
       	if ( searchEngineInt == 7 ) {
	    GovernmentAuction();
	}
       	if ( searchEngineInt == 8 ) {
	    HomeSteps();
	}
       	if ( searchEngineInt == 9 ) {
	    HomePath();
	}
       	if ( searchEngineInt == 10 ) {
	    HomeSalesGov();
	}
       	if ( searchEngineInt == 16 ) {
	    HudHomeStore();
	}
       	if ( searchEngineInt == 11 ) {
	    GSAGov();
	}
       	if ( searchEngineInt == 12 ) {
	    GovSales();
	}
       	if ( searchEngineInt == 13 ) {
	    LonestarOnline();
	}
       	if ( searchEngineInt == 14 ) {
	    GovDeals();
	}
       	if ( searchEngineInt == 15 ) {
	    IllinoisIbid();
	}
          
	try {
	    hsql.close();
	} 
	catch ( SQLException sqle ) { sqle.printStackTrace(); }

	return responseData;
    }
   
    public static void GovLiquidation() {
       String location = "";
       String ntt = "";
       String ntk = "";

       if ( !searchState.equals("ALL") ) {
           ntt = "US_" + searchState + "|" + searchString;
           location = "&amp;location=US_" + searchState;
           ntk = "P_Auction_Country_State|P_Lot_Title";
       }
       else { 
          ntt = searchString;
          location = "";
          ntk = "P_Lot_Title"; 
       }
    
       String message = "Ntt=" + ntt + "&amp;Ntk=" + ntk + "&amp;Ntx=mode+matchall|mode+matchall&amp;N=0&amp;Nty=1&amp;Ns=P_Lot_Number|0" + location + "&amp;words=" + searchString + "&amp;cmd=keyword";

       try {
        URL theUrl = new URL( "http://www.govliquidation.com/auction/endecaSearch?" + message );
        String resp = "";        
        BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
	    resp += line;
        }
        reader.close();

        int startIdx = resp.indexOf("<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" border=\"0\" WIDTH=\"748\" ALIGN=\"CENTER\" id=\"lots_table\">");
        int endIdx = resp.indexOf("<!-- Load the Brightcove JavaScript API -->");

        Parser htmlParser = new Parser();
        if ( endIdx > 0 &amp;&amp; startIdx > 0 ) {
          try {
	     htmlParser.setInputHTML( resp.substring( startIdx, endIdx ) );  
             NodeList nList = htmlParser.parse(null);
             if ( nList.size() > 0 ) {
	       NodeList trList = nList.elementAt(0).getChildren();
               for ( int i=0; i<trList.size(); i++ ) {
		   if ( trList.elementAt(i).getText().contains("resultsBackground1") || trList.elementAt(i).getText().contains("resultsBackground2") ) {
		     NodeList tdList = trList.elementAt(i).getChildren();
		     for ( int j=0; j<tdList.size(); j++ ) {
		       if ( (tdList.elementAt(j).getText()).trim().equals("TD VALIGN=\"top\" class=\"annotationText1\"") ) {
			  String resultsContent = (tdList.elementAt(j).toPlainTextString()).trim();
                          resultsContent = resultsContent.replaceAll("\"", "'" );
			  resultsContent = resultsContent.replaceAll("\n", "");
                          resultsContent = resultsContent.replaceAll("\t", "");

			  NodeList aList = tdList.elementAt(j).getChildren();
                          for ( int k=0; k<aList.size(); k++ ) {
			    if ( aList.elementAt(k).getText().contains("A HREF=\"http://www.govliquidation.com/auction/view") ) {
			       String anchorHref = aList.elementAt(k).getText().trim();
                               String[] pieces = anchorHref.split("\"");
                               anchorHref = pieces[1].trim();
                               
                               try {
                                 System.out.println( "INSERT INTO auction_records ( website, url, results_content ) VALUES ( 'http://www.govliquidation.com/', '" + anchorHref + "', '" +  resultsContent + "' )" );

			          stmt.executeUpdate( "INSERT INTO auction_records ( website, url, results_content ) VALUES ( 'http://www.govliquidation.com/', '" + anchorHref + "', '" +  resultsContent + "' )" );
                               } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                            }   
                          } 
                       }   
                     }
                   }
               }
             }
          } catch ( ParserException pe ) { pe.printStackTrace(); }
        }
       } catch ( MalformedURLException me ) { me.printStackTrace(); }
       catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void GSAAuctions() {
      if ( searchState.equals("ALL") ) {
       try {
	String message = "Continue=" + URLEncoder.encode("Continue");       
        
        URL theUrl = new URL("http://gsaauctions.gov/gsaauctions/gsaauctions/");
        HttpURLConnection conn = (HttpURLConnection) theUrl.openConnection();
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
        conn.setRequestProperty("User-Agent","Mozilla/5.0");
        OutputStream os = conn.getOutputStream();
        os.write(message.getBytes("UTF-8"));
        os.close();

        BufferedReader myReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        String resp = "";
        while ((line = myReader.readLine()) != null) {
	    resp += line;
        }
        myReader.close();
       
        int scIdx = resp.indexOf("name=\"scParam\" VALUE=\"");
        if ( scIdx > 0 ) {
	  String[] pieces = resp.substring( scIdx+10, scIdx+80 ).split("VALUE=\"");
          if ( pieces.length > 1 ) {          
	    String[] piecesII = pieces[1].split("\"");
	    String scParam =  piecesII[0].trim();

            int webPcmIdx = resp.indexOf("name=\"WEBPCMTRANSID\" VALUE=\"");
            if ( webPcmIdx > 1 ) {
	       pieces = resp.substring( webPcmIdx+10, webPcmIdx+80 ).split("VALUE=\"");
               if ( pieces.length > 0 ) {
		 piecesII = pieces[1].split("\"");
                 String webPcmParam = piecesII[0].trim();
                  
                 String msg2 = "scParam=" + URLEncoder.encode(scParam) + "&amp;WEBPCMTRANSID=" + URLEncoder.encode( webPcmParam ) + "&amp;sc=&amp;scAction=" + URLEncoder.encode("AUCALSRH") + "&amp;scRegn=&amp;scSalNo=&amp;scLotNo=&amp;scQuery=&amp;query=&amp;order=&amp;af2eq=&amp;scCatCode=&amp;scStCode=&amp;scPassUpd=&amp;scSrchDesc=" + URLEncoder.encode( searchString ) + "&amp;scSrchDescCtxt=&amp;catMenuNew=";

                 URL url2 = new URL("http://gsaauctions.gov/gsaauctions/aucindx");
                 HttpURLConnection con2 = (HttpURLConnection) url2.openConnection();
                 con2.setDoOutput(true);
                 con2.setRequestMethod("POST");
                 con2.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
                 con2.setRequestProperty("User-Agent","Mozilla/5.0");

                 OutputStream writer = con2.getOutputStream();
                 writer.write(msg2.getBytes("UTF-8"));
	         writer.close();
             
                 BufferedReader leer = new BufferedReader(new InputStreamReader(con2.getInputStream()));
                 line = "";
                 resp = "";
                 while ((line = leer.readLine()) != null) {
	          resp += line;
                 }
                 leer.close();

                 int startIdx = resp.indexOf("var tab=[");
                 int endIdx = resp.indexOf("bldTr();"); 

                 pieces =  resp.substring( startIdx, endIdx ).split(Pattern.quote("["));
                 if ( pieces.length > 1 ) {
                   piecesII = pieces[1].split(Pattern.quote("]"));
		   pieces = piecesII[0].split("\",\"");

                   String resultsContent = "";
                   String anchorHref = "";
                   if ( pieces.length > 6 ) {
                    for ( int j=0; j<pieces.length; j+=7 ) {
		     resultsContent = pieces[j].replace("\"","") + " " + pieces[j+1] + " " + pieces[j+2] + " " + pieces[j+3] + " " + pieces[j+4] + " " + pieces[j+5] + " " + pieces[j+6].replace("\",","");
                     anchorHref = "javascript:itemSel('" + pieces[j+1].substring(0,11) + "','" + pieces[j+1].substring(11) + "');";
                     try {
                       stmt.executeUpdate( "INSERT INTO auction_records ( website, url, results_content ) VALUES ( 'http://gsaauctions.gov/', '" + anchorHref + "', '" + resultsContent + "' )" );
                     } catch ( SQLException sqle ) { sqle.printStackTrace(); }
		    }
                   }
		 }
	       }
	    }
          }
	}
         
       } catch ( MalformedURLException me ) { me.printStackTrace(); }
       catch ( IOException ioe ) { ioe.printStackTrace(); }
      }
    }

    public static void IRSAuctions() {
      if ( searchState.equals("ALL") ) {
        try {         
	 URL theUrl = new URL("http://search.treas.gov/search?q=" + URLEncoder.encode(searchString) + "&amp;output=xml_no_dtd&amp;sort=date%3AD%3AL%3Ad1&amp;ie=UTF-8&amp;client=auctions&amp;oe=UTF-8&amp;proxystylesheet=auctions&amp;site=Auctions");
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	    resp += line;
         }
         reader.close();

         int startIdx =  resp.indexOf("<p><font size=\"-2\">");
         int endIdx = resp.indexOf("In order to show you");

         if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
           Parser htmlParser = new Parser();
           try {
             htmlParser.setInputHTML( resp.substring(startIdx,endIdx) );
             NodeList nList = htmlParser.parse(null);
             
             for ( int i=0; i<nList.size(); i++ ) {
	      if ( nList.elementAt(i).getText().startsWith("p") ) {
		NodeList pChildList = nList.elementAt(i).getChildren();
                for ( int j=0; j<pChildList.size(); j++ ) {
		  String anchorHref = "";
		  if ( pChildList.elementAt(j).getText().startsWith("a href=\"http://www.treasury") ) {
		    String[] pieces = pChildList.elementAt(j).getText().split("\"");
                    anchorHref = pieces[1].trim();      
                  }
                  if ( pChildList.elementAt(j).getText().startsWith("span class=\"s\"") ) {
		    String resultsContent = pChildList.elementAt(j).toPlainTextString().trim();
                    resultsContent = resultsContent.replaceAll("\"", "");
		    resultsContent = resultsContent.replaceAll("\n", "");
                    try {
                      stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://search.treas.gov/', '" + anchorHref + "', '" + resultsContent + "' )" );
                    } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                  } 
                }   
              }   
             }            
           } catch ( ParserException pe ) { pe.printStackTrace(); }                             
         }
	} catch ( IOException ioe ) { ioe.printStackTrace(); }
         
      }
    }

    public static void BidCorp() {
      if ( searchState.equals("ALL" ) ) {
        try {
	  URL theUrl = new URL("http://www.bidcorp.com/AdvancedSearch.aspx"); 
          String resp = "";        
          BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
          String line;
          while ((line = reader.readLine()) != null) {
	    resp += line;
          }
          reader.close();
     
          int vsIdx = resp.indexOf("id=\"__VIEWSTATE\"");
          int endIdx = resp.indexOf("=\" />");
          String viewState = resp.substring(vsIdx,endIdx+1).split("value=\"")[1];
          vsIdx = resp.indexOf("id=\"__EVENTVALIDATION\"");
          endIdx = resp.indexOf("<table class=\"mainTable\""); 
	  String[] pieces = resp.substring(vsIdx,endIdx).split("value=\"");
          String evtValidation = pieces[1].split("\"")[0].trim();
          
          String message = "__EVENTTARGET=&amp;__EVENTARGUMENT=&amp;__VIEWSTATE=" + URLEncoder.encode(viewState) + "&amp;__EVENTVALIDATION=" + URLEncoder.encode(evtValidation) +  "&amp;ctl00$ContentPlaceHolder1$txtKeywords=" + URLEncoder.encode( searchString ) + "&amp;ctl00$ContentPlaceHolder1$rdoKeywordStatus=" + URLEncoder.encode("3") + "&amp;ctl00$ContentPlaceHolder1$btnSubmitKeyword=" + URLEncoder.encode("Submit") + "&amp;ctl00$ContentPlaceHolder1$txtLotNumber=";

          URL url2 = new URL("http://www.bidcorp.com/AdvancedSearch.aspx");
          HttpURLConnection conn = (HttpURLConnection) url2.openConnection();
          conn.setDoOutput(true);
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          conn.setRequestProperty("User-Agent","Mozilla/5.0");

          OutputStream writer = conn.getOutputStream();
          writer.write(message.getBytes("UTF-8"));
	  writer.close();
             
          BufferedReader myReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
          line = "";
          resp = "";
          while ((line = myReader.readLine()) != null) {
	     resp += line;
          }
          myReader.close();

          int startIdx = resp.indexOf("<table cellspacing=\"0\" cellpadding=\"4\"");
          endIdx = resp.indexOf("<div style=\"margin: 5px; ");

          if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) { 
	    Parser htmlParser = new Parser();
            try {
              htmlParser.setInputHTML( resp.substring(startIdx,endIdx) );
              NodeList nList = htmlParser.parse(null);
              if ( nList.size() > 0 ) {
		NodeList trList = nList.elementAt(0).getChildren();
                for ( int i=0; i<trList.size(); i++ ) {
		  if ( trList.elementAt(i).getText().contains("bgcolor=\"White\"") || trList.elementAt(i).getText().contains("bgcolor=\"#CCCCCC\"") ) {
		     NodeList tdList = trList.elementAt(i).getChildren();
                     if ( tdList.size() > 2 ) {
		        String resultsContent = (tdList.elementAt(2).toPlainTextString()).trim();
                        resultsContent = resultsContent.replaceAll("\"", "");
		        resultsContent = resultsContent.replaceAll("\n", "");
                        resultsContent = resultsContent.replaceAll("\t", ""); 
           
                        String[] piecesII = (tdList.elementAt(2).getChildren().elementAt(1).getText()).split("'");
                        String anchorHref = "http://www.bidcorp.com/" + piecesII[1].trim();
                        try {
			   
                          stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.bidcorp.com/', '" + anchorHref + "', '" + resultsContent + "' )" );

                        } catch ( SQLException sqle ) { sqle.printStackTrace(); }

                     }
                  }             
                }
              }
	    } catch ( ParserException pe ) { pe.printStackTrace(); }
          }
        } catch ( IOException ioe ) { ioe.printStackTrace(); }   
      }
    }

    public static void bid4Assets() {
	try { 
            String stateSearch = "";
            if ( searchState.equals("ALL") ) {
		stateSearch = "all"; }
            else { stateSearch = searchState; }
             
	    String message = "fuseaction=" + URLEncoder.encode("search") + "&amp;type=" + URLEncoder.encode( "powerSearch" ) + "&amp;criteria=" + URLEncoder.encode( searchString ) + "&amp;keywordType=" + URLEncoder.encode( "allWords" ) + "&amp;channel=" + URLEncoder.encode("all") + "&amp;cat2=" + URLEncoder.encode("all") + "&amp;cat3=" + URLEncoder.encode("all") + "&amp;LocationChoice=" + URLEncoder.encode("1") + "&amp;locatedState=" + URLEncoder.encode( stateSearch ) + "&amp;ZIp=&amp;ZipRadius=" + URLEncoder.encode("1") + "&amp;assetstatus=" + URLEncoder.encode("Live") + "&amp;DateHistory=" + URLEncoder.encode("6") + "&amp;sort=" + URLEncoder.encode("bidCloseTime");

	    URL theUrl = new URL( "http://www.bid4assets.com/search/index.cfm" );
	    HttpURLConnection connection = (HttpURLConnection) theUrl.openConnection();
	    connection.setDoOutput( true );
	    connection.setRequestMethod( "POST" );
	    connection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );

	    OutputStream writer = connection.getOutputStream();
	    writer.write( message.getBytes("UTF-8") );
	    writer.close();

	    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
	    String line;
	    String responseContent = "";

	    while ((line = reader.readLine()) != null) {
		responseContent += line;       
	    }
	    reader.close();

	    int startIdx = responseContent.indexOf( "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">" );
	    int endIdx = responseContent.indexOf( "<!-- google_ad_section_end" ); 

            if ( startIdx<0 || endIdx<0 ) return;

	    Parser htmlParser = new Parser();
	    try {
		//  System.out.println( startIdx + " " + endIdx );
	      if ( startIdx > 0 &amp;&amp; endIdx > 0 ) { 
               
		htmlParser.setInputHTML( responseContent.substring( startIdx, endIdx ) );
		NodeList nList = htmlParser.parse( null );               
	
		if ( nList.size() > 4 ) {
		   
		   NodeList trList = nList.elementAt(4).getChildren();

		   for ( int i=0; i<trList.size(); i++ ) {
		     if ( !trList.elementAt(i).toPlainTextString().trim().equals("") ) {
		       String resultsContent = trList.elementAt(i).toPlainTextString().trim();
                       resultsContent = resultsContent.replaceAll("\"", "");
		       resultsContent = resultsContent.replaceAll("\n", " ");
                       resultsContent = resultsContent.replaceAll("\t", " ");
                       resultsContent = resultsContent.replace("\\", "");
                       resultsContent = resultsContent.replaceAll("'", "");
                      
                       NodeList tdList = trList.elementAt(i).getChildren();
                      try {
                       for ( int j=0; j<tdList.size(); j++ ) {
			 if ( tdList.elementAt(j).getText().contains("mediumArial02") ) {
			     NodeList aList = tdList.elementAt(j).getChildren();
                             for ( int k=0; k<aList.size(); k++ ) {
			       if ( aList.elementAt(k).getText().contains("href") ) {
				 String href = aList.elementAt(k).getText().trim();
                                
                                  String anchorHref = href.split("=\"")[1];
                                  anchorHref = "http://www.bid4assets.com/" + anchorHref.substring(0,anchorHref.length()-1);                  
				  //System.out.println( "6" );
                                  try {
                                    stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.bid4assets.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                                  } catch ( SQLException sqle ) { sqle.printStackTrace(); }
				
                               }   
                             }
                         }
		       }
                      } catch ( NullPointerException npe ) { npe.printStackTrace(); }
		     }
		   }
		}
	      }
	    } catch ( ParserException pe ) { pe.printStackTrace(); }      
	} catch ( IOException ioe ) { ioe.printStackTrace(); }
    }
   
    public static void BankruptcySales() {
      if ( searchState.equals("ALL" ) ) {
       try {
	 String msg = "keyWord=" + URLEncoder.encode( searchString );

         URL theUrl = new URL("http://www.bankruptcysales.com/assets_search2.cfm"); 
         HttpURLConnection conn = (HttpURLConnection) theUrl.openConnection();
         conn.setDoOutput(true);        
         conn.setRequestMethod("POST");
         conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");           
         conn.setRequestProperty("User-Agent","Mozilla/5.0"); 
         OutputStream os = conn.getOutputStream();
         os.write(msg.getBytes("UTF-8"));
         os.close();

         BufferedReader lector = new BufferedReader(new InputStreamReader(conn.getInputStream()));
         String line;
         String resp = "";
         while ((line = lector.readLine())!= null) {
	   resp = resp.concat(line);
         }
         lector.close();

         int startIdx = resp.indexOf("<!-- InstanceBeginEditable name=\"Body\" -->");
         int endIdx = resp.indexOf("CLASS=\"bottomLinks\"");

         Parser htmlParser = new Parser();
         try {
	   htmlParser.setInputHTML( resp.substring(startIdx,endIdx) );
           NodeList nList = htmlParser.parse(null);
           
           for ( int i=0; i<nList.size(); i++ ) {
	     if ( nList.elementAt(i).getText().startsWith("TABLE WIDTH=\"95%\"") ) {
	       NodeList nextChildren = nList.elementAt(i).getChildren();
               for ( int j=0; j<nextChildren.size(); j++ ) {
		 if ( nextChildren.elementAt(j).getText().equals("TR") ) {
		   NodeList nxtChildren = nextChildren.elementAt(j).getChildren();
                   if ( nxtChildren.size() > 0 ) {
		     NodeList pChildren = nxtChildren.elementAt(1).getChildren();
                     for ( int k=0; k<pChildren.size(); k++ ) {
		       if ( pChildren.elementAt(k).getText().startsWith("TABLE WIDTH=\"95%\"") ) {
			  NodeList trList = pChildren.elementAt(k).getChildren();
                          for ( int l=2; l<trList.size(); l++ ) {
			     if ( !trList.elementAt(l).toPlainTextString().trim().equals("") ) {
			       String resultsContent = trList.elementAt(l).toPlainTextString().trim();
                               resultsContent = resultsContent.replaceAll("\t","");
                               resultsContent = resultsContent.replaceAll("\n","");                                  
                               while ( resultsContent.contains("  ") ) {
				  resultsContent = resultsContent.replaceAll("  ","");   
                               }
                             
                               String[] hrefCandidates = trList.elementAt(l).toHtml().split("HREF=\"");
                               if ( hrefCandidates.length > 0 ) {
				  String anchorHref = hrefCandidates[1].split("\"")[0];
                                  anchorHref = "http://www.bankruptcysales.com/" + anchorHref;
                                  try {
				      //System.out.println(  "INSERT INTO auction_records VALUES ( 'http://www.bankruptcysales.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                                     stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.bankruptcysales.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                                  } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                               }
                               
                             }    
                          }
                       } 
                     }   
                   }
                 }     
               } 
             }  
           }

         } catch ( ParserException pe ) { pe.printStackTrace(); }
	} catch ( IOException ioe ) { ioe.printStackTrace(); }
      }
    }

    public static void PublicSurplus() {
      try {
	String stateSearch = searchState;  
	if ( searchState.equals("ALL") ) stateSearch = "";

	String message = "http://www.publicsurplus.com/sms/browse/search?posting=y&amp;slth=&amp;page=0&amp;sortBy=timeLeft&amp;keyWord=" + searchString + "&amp;catId=-1&amp;endHours=-1&amp;startHours=-1&amp;lowerPrice=0&amp;higherPrice=0&amp;milesLocation=-1&amp;zipCode=&amp;region=" + "all%2C" + stateSearch;

	URL theUrl = new URL( message );
        String resp = "";        
        BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
	   resp += line;
        }
        reader.close(); 
 
        int startIdx = resp.indexOf("<div class=\"SepTable\">");
        int endIdx = resp.indexOf("Hide Images");

        if ( startIdx > 0 &amp;&amp; endIdx > 0 ) {
        //System.out.println( resp.substring(startIdx,endIdx) );

         Parser htmlParser = new Parser();
         try {
	  htmlParser.setInputHTML(resp.substring(startIdx,endIdx));
          NodeList nList = htmlParser.parse(null);   

          for ( int i=0; i<nList.size(); i++ ) {
	    if ( nList.elementAt(i).getText().equals("table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" class=\"tabCurr\"") ) {
	       NodeList tHeadList = nList.elementAt(i).getChildren();
               for ( int j=4; j<tHeadList.size(); j++ ) {
		 if ( tHeadList.elementAt(j).getText().startsWith("tr") ) {
		     String resultsContent = tHeadList.elementAt(j).toPlainTextString().trim();
		     resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                     resultsContent = resultsContent.replaceAll("\n","");
                     resultsContent = resultsContent.replaceAll("\t","");
                     while ( resultsContent.contains("  ") ) {
			 resultsContent = resultsContent.replaceAll("  "," ");
                     }
                     //System.out.println( resultsContent );
		     String[] pieces = tHeadList.elementAt(j).toHtml().split("href=\"");
                     String[] piecesII = pieces[1].split("\"");
                     String anchorHref = "http://www.publicsurplus.com" + piecesII[0].trim();
                     try {
		        stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://http://www.publicsurplus.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                     } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                 }
               } 
            }  
          }

         } catch ( ParserException pe ) { pe.printStackTrace(); }
	}
      } catch ( IOException ioe ) { ioe.printStackTrace(); }    
    }

    public static void GovernmentAuction() {
      if ( searchState.equals("ALL" ) ) {
	String message = "http://auctions.governmentauction.com/view-auctions/individual-lots/?key=" + searchString + "&amp;page=1&amp;cat=&amp;catm=any&amp;order=timeleft&amp;live=yes&amp;timed=yes&amp;regular=yes&amp;buynow=yes&amp;makeoffer=yes&amp;auctioneer=&amp;minprice=&amp;maxprice=&amp;items=48";
        try {
	 URL theUrl = new URL( message );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	   resp += line;
         }
         reader.close(); 

         int startIdx = resp.indexOf("<div id=\"lac");
         int endIdx = resp.indexOf("<div id=\"footer\">");
         
         Parser prse = new Parser();
         try {
	   prse.setInputHTML( resp.substring(startIdx,endIdx) );
           NodeList nList = prse.parse(null);   

           for ( int i=0; i<nList.size(); i++ ) {
	     if ( nList.elementAt(i).getText().contains("id=\"lac") ) {
		NodeList divList = nList.elementAt(i).getChildren();
                for ( int j=0; j<divList.size(); j++ ) {
		  if ( divList.elementAt(j).getText().equals("div class=\"name\"") ) {
		    String resultsContent = divList.elementAt(j).toPlainTextString();
                    resultsContent = resultsContent.replaceAll("\n","");
                    resultsContent = resultsContent.replaceAll("\t","");
                    while ( resultsContent.contains("  ") ) {
		       resultsContent = resultsContent.replaceAll("  "," ");
                    }
                    //System.out.println( resultsContent );
                    String[] pieces = divList.elementAt(j).toHtml().split("href=\"");
                    String[] piecesII = pieces[1].split("\"");
                    String anchorHref = piecesII[0].trim();
                    anchorHref = "http://auctions.governmentauction.com" + anchorHref;
                    try {
		        stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://auctions.governmentauction.com', '" + anchorHref + "', '" + resultsContent + "' )" );
                     } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                  }  
                }
             }
           }
         } catch ( ParserException pe ) { pe.printStackTrace(); } 
        } catch ( IOException ioe ) { ioe.printStackTrace(); }
      }
    }

    public static void HomeSteps() {
      if ( searchState.equals("ALL" ) ) {
	  return;
      }
      String msg = "City=&amp;County=&amp;State=" + URLEncoder.encode(searchState) + "&amp;Zip=&amp;PriceRangeLow=" + URLEncoder.encode("*") + "&amp;PriceRangeHigh=" + URLEncoder.encode("*") + "&amp;TotalRooms=" + URLEncoder.encode("*") + "&amp;NumberBedrooms=" + URLEncoder.encode("*") + "&amp;NumberBathrooms=" + URLEncoder.encode("*") + "&amp;B1=Find Homes&amp;IPP=50";

      try {
        URL theUrl = new URL("http://www.homesteps.com/cgi-bin/dynamic/formsearch.cgi"); 
        HttpURLConnection conn = (HttpURLConnection) theUrl.openConnection();
        conn.setDoOutput(true);        
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");           
        conn.setRequestProperty("User-Agent","Mozilla/5.0"); 
        OutputStream os = conn.getOutputStream();
        os.write(msg.getBytes("UTF-8"));
        os.close();

        BufferedReader myReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        String resp = "";
        while ((line = myReader.readLine())!= null) {
          resp = resp.concat(line);
        }
        myReader.close();
     
        int startIdx = resp.indexOf("<table cellpadding=1 cellspacing=1 class=tblHomesteps>");
        int endIdx = resp.indexOf("Freddie Mac takes");
 
        Parser prsr = new Parser();
        try {
	  prsr.setInputHTML(resp.substring(startIdx,endIdx));
          NodeList nList = prsr.parse(null);
          for ( int i=0; i<nList.size(); i++ ) {            
	    if ( nList.elementAt(i).getText().equals("table cellpadding=1 cellspacing=1 class=tblHomesteps") ) {
	       NodeList trList = nList.elementAt(i).getChildren();
               for ( int j=2; j<trList.size(); j++ ) {
		 if ( trList.elementAt(j).getText().equals("tr") ) {
		    String resultsContent = trList.elementAt(j).toPlainTextString();
                    resultsContent = resultsContent.replaceAll("\n","");
                    resultsContent = resultsContent.replaceAll("\t","");
                    while ( resultsContent.contains("  ") ) {
		       resultsContent = resultsContent.replaceAll("  "," ");
                    }
                    String anchorHref = "http://www.homesteps.com/featuresearch.html";
                    try {
		        stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.homesteps.com/featuresearch.html', '" + anchorHref + "', '" + resultsContent + "' )" );
                     } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                 } 
               }
            }
          }
        } catch ( ParserException pe ) { pe.printStackTrace(); }
      } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void HomePath() {
      if ( searchState.equals("ALL" ) ) {
	  return;
      }

      String message = "http://www.homepath.com/search.html?st=" + searchState + "&amp;cno=000&amp;ci=&amp;zip=&amp;src_ref=&amp;mlsid=&amp;pi=&amp;pa=&amp;bdi=&amp;bhi=&amp;x=26&amp;y=11&amp;ms=&amp;xs=";
      try {
	 URL ubl = new URL( message );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(ubl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	   resp += line;
         }
         reader.close(); 

         int startIdx = resp.indexOf("<table class=\"multipleLinesSearchResults\"");
         int endIdx = resp.indexOf("Get FREE HomePath");
 
         if ( startIdx > 0 &amp;&amp; endIdx > 0 ) {
	   Parser htmlParser = new Parser();
           try {
	     htmlParser.setInputHTML(resp.substring(startIdx,endIdx));
             NodeList nList = htmlParser.parse(null);

             for ( int i=0; i<nList.size(); i++ ) {
	       if ( nList.elementAt(i).getText().equals("table class=\"multipleLinesSearchResults\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"") ) {
		  NodeList trList = nList.elementAt(i).getChildren();
                  for ( int j=0; j<trList.size(); j++ ) {
		    if ( trList.elementAt(j).getText().startsWith("tr class") ) {
		      String resultsContent = trList.elementAt(j).toPlainTextString().trim();
                      resultsContent = resultsContent.replaceAll("\n","");
                      resultsContent = resultsContent.replaceAll("\t","");
                      resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                      resultsContent = resultsContent.replaceAll("SaveMap","");
                      while ( resultsContent.contains("  ") ) {
		        resultsContent = resultsContent.replaceAll("  "," ");
                      }
                      //System.out.println( resultsContent );
                      String[] pieces = trList.elementAt(j).toHtml().split("href=\"");
                      String[] piecesII = pieces[1].split("\"");
                      String anchorHref = piecesII[0].trim();
                      anchorHref = anchorHref;
                      anchorHref = "http://www.homepath.com" + anchorHref;
                      if ( !resultsContent.equals("") ) {
                        try {
		          stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.homepath.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                        } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                      }
                    }  
                  } 
               }  
             }
           } catch ( ParserException pe ) { pe.printStackTrace(); }
	 }
      } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void HomeSalesGov() {
      if ( searchState.equals("ALL" ) ) {
	  return;
      }  
      String msg = "selectedCities=" + URLEncoder.encode("ALL") + "&amp;selBedrooms=&amp;selBaths=&amp;pageAction=" + URLEncoder.encode("Search for Properties") + "&amp;stateName=" + URLEncoder.encode( stateMap.get(searchState) ) + "&amp;state=" + URLEncoder.encode(searchState) + "&amp;propertyType=" + URLEncoder.encode("RESIDENTIAL");
      try {     
        URL theUrl = new URL("http://www.homesales.gov/homesales/mainAction.do"); 
        HttpURLConnection conn = (HttpURLConnection) theUrl.openConnection();
        conn.setDoOutput(true);        
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");           
        conn.setRequestProperty("User-Agent","Mozilla/5.0"); 
        OutputStream os = conn.getOutputStream();
        os.write(msg.getBytes("UTF-8"));
        os.close();

        BufferedReader myReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        String resp = "";
        while ((line = myReader.readLine())!= null) {
          resp = resp.concat(line);
        }
        myReader.close();

        int startIdx = resp.indexOf("<table width=\"80%\" align=\"center\" border=\"0\" rules=\"none\">");
        int endIdx = resp.indexOf(" Total Result Pages:");
        
        if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
         try {
	  Parser prs = new Parser();
          prs.setInputHTML(resp.substring(startIdx,endIdx));

          NodeList nList = prs.parse(null);
          for ( int i=0; i<nList.size(); i++ ) {     
	    if ( nList.elementAt(i).getText().startsWith("table width=\"80%\"") ) {
	       NodeList trList = nList.elementAt(i).getChildren();
               for ( int j=0; j<trList.size(); j++ ) {
		 if ( trList.elementAt(j).getText().equals("tr") ) {
		    String resultsContent = trList.elementAt(j).toPlainTextString();
                    resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                    resultsContent = resultsContent.replaceAll("\n","");
                    resultsContent = resultsContent.replaceAll("\t","");
                    while ( resultsContent.contains("  ") ) {
		       resultsContent = resultsContent.replaceAll("  "," ");
                    }
                   
                    String[] pieces = trList.elementAt(j).toHtml().split("href=\"");
                    if ( pieces.length > 1 ) {
                     String[] piecesII = pieces[1].split("\"");
                     if ( piecesII.length > 0 ) {
                      String anchorHref = piecesII[0].trim();
                      anchorHref = anchorHref;
                      try {
		        stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.homepath.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                      } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                     }
                    }
                 }  
               }
            }
          }
         } catch ( ParserException pe ) { pe.printStackTrace(); }
        }
      } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void HudHomeStore() {
      if ( searchState.equals("ALL" ) ) {
	  return;
      }

      String message = "https://hudhomestore.secureportalk.net/HUD/PropertySearchResult.aspx?PageId=1&amp;zipCode=&amp;city=&amp;county=&amp;sState="+searchState+"&amp;fromPrice=0&amp;toPrice=0&amp;caseNumber=&amp;bed=0&amp;bath=0&amp;street=&amp;buyerType=0&amp;specialProgram=&amp;Status=0&amp;OrderbyName=SCASENUMBER&amp;OrderbyValue=ASC&amp;sPageSize=50";
      try {
	 URL ubl = new URL( message );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(ubl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	   resp += line;
         }
         reader.close(); 

         int startIdx = resp.indexOf("<tr class=\"FormTablerow\"");
         int endIdx = resp.indexOf("<!-- =============  Data List");

         try {
	   Parser p = new Parser();
           p.setInputHTML(resp.substring(startIdx,endIdx));           
           NodeList nList = p.parse(null);
           for ( int i=0; i<nList.size(); i++ ) {  
	     if ( nList.elementAt(i).getText().startsWith("tr class=\"FormTablerow") ) {
                 String resultsContent = nList.elementAt(i).toPlainTextString();
                 resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                 resultsContent = resultsContent.replaceAll("\n","");
                 resultsContent = resultsContent.replaceAll("\t","");
                 resultsContent = resultsContent.replaceAll("Exclusive","");
                 resultsContent = resultsContent.replaceAll("View","");
                 resultsContent = resultsContent.replaceAll("Street","");
                 resultsContent = resultsContent.replaceAll("Map it","");
                 resultsContent = resultsContent.replaceAll("Email","");
                 resultsContent = resultsContent.replaceAll("Info","");
                 resultsContent = resultsContent.replaceAll("Extended","");
                 resultsContent = resultsContent.replaceAll("Lottery","");
                 while ( resultsContent.contains("  ") ) {
		    resultsContent = resultsContent.replaceAll("  "," ");
                 }
                 //System.out.println( resultsContent );
                 NodeList tdList = nList.elementAt(i).getChildren();
                 for ( int j=0; j<tdList.size(); j++ ) {
		   if ( tdList.elementAt(j).getText().startsWith("td align=\"center\" valign=\"middle\"") ) {
		     NodeList aList = tdList.elementAt(j).getChildren();
                     for ( int k=0; k<aList.size(); k++ ) {
		       if ( aList.elementAt(k).getText().startsWith("a href=\"#;\"") ) {
			   String[] pieces = aList.elementAt(k).getText().split(Pattern.quote("getGoogleTranslationstring(&amp;#039;"));
                         if ( pieces.length > 0 ) {
			   String[] piecesII = pieces[1].split(Pattern.quote("&amp;#039;"));
                           if ( piecesII.length > 0 ) {
			     String anchorHref = piecesII[0].trim();
                             try {
			       System.out.println( "INSERT INTO auction_records VALUES ( 'http://www.hudhomestore.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
		                stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.hudhomestore.com/', '" + anchorHref + "', '" + resultsContent + "' )" );
                             } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                           }  
                         }  
                       }  
                     }  
                   }   
                 }
             }                 
           }
         } catch ( ParserException pe ) { pe.printStackTrace(); }
      } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void GSAGov() {
      if ( searchState.equals("ALL" ) ) {
	  return;
      }

      String message = "https://extportal.pbs.gsa.gov/ResourceCenter/PRHomePage/searchProperty.do?state=5&amp;amp;statename=" + stateMap.get(searchState).toUpperCase() +  "&amp;amp;propType=&amp;amp;propTypeName=ALL&amp;amp;searchType=S";
      try {
	 URL ubl = new URL( message );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(ubl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	   resp += line;
         }
         reader.close(); 

         int startIdx = resp.indexOf("<div class=\"cmSectionText\">");
         int endIdx = resp.indexOf("<!-- div cmSectionText -->");
           
        if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
	  Parser p = new Parser();
	  try {   
	    p.setInputHTML( resp.substring(startIdx,endIdx) );
            NodeList nList = p.parse(null); 

            for ( int i=0; i<nList.size(); i++ ) {
	      if ( nList.elementAt(i).getText().startsWith("div class=\"cmSectionText\"") ) {
		NodeList divChildren = nList.elementAt(i).getChildren();
                for ( int j=0; j<divChildren.size(); j++ ) {
		  if ( divChildren.elementAt(j).getText().contains("D1D1D1") ) {
		    String resultsContent = divChildren.elementAt(j).toPlainTextString().trim();
                    resultsContent = resultsContent.replaceAll("Click here for more information","");
                    resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                    resultsContent = resultsContent.replaceAll("\n","");
                    resultsContent = resultsContent.replaceAll("\t","");
                    resultsContent = resultsContent.replaceAll("\"","");
                    while ( resultsContent.contains("  ") ) {
		       resultsContent = resultsContent.replaceAll("  "," ");
                    }  
                    //System.out.println( resultsContent );  
                    String htm = divChildren.elementAt(j).toHtml();
                    //System.out.println( htm );  
                    int hrefIdx = htm.indexOf("loadProperty.do");
                    if ( hrefIdx > 0 ) {
		      String[] pieces = htm.substring(hrefIdx,hrefIdx+34).split(">");
                      if ( pieces.length > 0 ) {
			 String anchorHref = pieces[0].substring(0,pieces[0].length()-1);
                         anchorHref = "https://extportal.pbs.gsa.gov/ResourceCenter/PRHomePage/" + anchorHref;
                          try {
			      //System.out.println( "INSERT INTO auction_records VALUES ( 'https://propertydisposal.gsa.gov/', '" + anchorHref + "', '" + resultsContent + "' )" );
		                stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'https://propertydisposal.gsa.gov/', '" + anchorHref + "', '" + resultsContent + "' )" );
                          } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                      }
                    }
                  } 
                } 
              }  
            }  
	  } catch ( ParserException pe ) { pe.printStackTrace(); }
        }
      } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void GovSales() {
      String msg = "http://www.govsales.gov/fassys/fassys/?function=010000000000";
      
      try {
	URL ubl = new URL( msg );
        String resp = "";        
        BufferedReader reader = new BufferedReader(new InputStreamReader(ubl.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
	   resp += line;
        }
        reader.close(); 

        String scParam = "";
	int scParamIdx = resp.indexOf("name=scParam VALUE=\"");
        if ( scParamIdx > 0 ) {
	   scParam = resp.substring(scParamIdx, scParamIdx+80);
	   String[] pieces = scParam.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scParam = piecesII[0].trim();
             } 
	   }
        }
        String webPcm = "";
        int webPcmIdx = resp.indexOf("WEBPCMTRANSID");
        if ( webPcmIdx > 0 ) {
	   webPcm = resp.substring(webPcmIdx, webPcmIdx+40);
           String[] pieces = webPcm.split("VALUE=");
           if ( pieces.length > 1 ) {
             String[] piecesII =  pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
                webPcm = piecesII[1].trim();
             }  
           }
        }

        String msg2 = "scParam=" + URLEncoder.encode( scParam ) + "&amp;scCurTabCat=" + URLEncoder.encode("010000000000") + "&amp;scSelTabCat=" + URLEncoder.encode("010000000000") + "&amp;scSelLink=" + URLEncoder.encode("GS") + "&amp;scGSName=" + URLEncoder.encode( searchString.toUpperCase() ) + "&amp;scGSOptn=" + URLEncoder.encode("1") + "&amp;scSelState=&amp;scSelBCCat=&amp;scSelRow=&amp;scSelCatList=&amp;scSeeAllCat=&amp;WEBPCMTRANSID=" + URLEncoder.encode( webPcm );

        URL usl = new URL("http://www.govsales.gov/fassys/fasallcat/");
        HttpURLConnection conn = (HttpURLConnection) usl.openConnection();
        conn.setDoOutput(true);        
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");           
        conn.setRequestProperty("User-Agent","Mozilla/5.0"); 
        OutputStream os = conn.getOutputStream();
        os.write(msg2.getBytes("UTF-8"));
        os.close();

        BufferedReader lecteur = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String rayo;
        String resp2 = "";
        while ((rayo = lecteur.readLine())!= null) {
	    resp2 += rayo;
        }
        lecteur.close();

        scParam = "";
	scParamIdx = resp2.indexOf("name=scParam VALUE=\"");
        if ( scParamIdx > 0 ) {
	   scParam = resp2.substring(scParamIdx, scParamIdx+80);
	   String[] pieces = scParam.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scParam = piecesII[0].trim();
             } 
	   }
        }
        String scStoreLocal1 = "";
	int scSL1Idx = resp2.indexOf("name=scStoreLocal1");
        if ( scSL1Idx > 0 ) {
	   scStoreLocal1 = resp2.substring(scSL1Idx, scSL1Idx+160);
	   String[] pieces = scStoreLocal1.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scStoreLocal1 = piecesII[0].trim();
             } 
	   }
        }
        String scStoreLocal2 = "";
	int scSL2Idx = resp2.indexOf("name=scStoreLocal2");
        if ( scSL1Idx > 0 ) {
	   scStoreLocal2 = resp2.substring(scSL2Idx, scSL2Idx+160);
	   String[] pieces = scStoreLocal2.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scStoreLocal2 = piecesII[0];
             } 
	   }
        }
        String scStoreLocal3 = "";
	int scSL3Idx = resp2.indexOf("name=scStoreLocal3");
        if ( scSL3Idx > 0 ) {
	   scStoreLocal3 = resp2.substring(scSL3Idx, scSL3Idx+160);
	   String[] pieces = scStoreLocal3.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scStoreLocal3 = piecesII[0];
             } 
	   }
        }
        String scStoreLocal5 = "";
	int scSL5Idx = resp2.indexOf("name=scStoreLocal5");
        if ( scSL5Idx > 0 ) {
	   scStoreLocal5 = resp2.substring(scSL5Idx, scSL5Idx+160);
	   String[] pieces = scStoreLocal5.split("VALUE=\"");
           if ( pieces.length > 1 ) {
             String[] piecesII = pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
		scStoreLocal5 = piecesII[0];
             } 
	   }
        }
        webPcm = "";
        webPcmIdx = resp2.indexOf("WEBPCMTRANSID");
        if ( webPcmIdx > 0 ) {
	   webPcm = resp2.substring(webPcmIdx, webPcmIdx+40);
           String[] pieces = webPcm.split("VALUE=");
           if ( pieces.length > 1 ) {
             String[] piecesII =  pieces[1].split("\"");
             if ( piecesII.length > 1 ) {
                webPcm = piecesII[1].trim();
             }  
           }
        }

        String msg3 = "scParam=" + URLEncoder.encode( scParam ) + "&amp;scStoreLocal1=" + URLEncoder.encode( scStoreLocal1 ) + "&amp;scStoreLocal2=" + URLEncoder.encode( scStoreLocal2 ) + "&amp;scStoreLocal3=" + URLEncoder.encode( scStoreLocal3 ) + "&amp;scStoreLocal4=&amp;scStoreLocal5=" + URLEncoder.encode( scStoreLocal5 ) + "&amp;scStoreLocal6=&amp;scStoreLocal7=&amp;scStoreLocal8=&amp;scStoreLocal9=&amp;scStoreLocal10=&amp;scStoreLocal11=&amp;scStoreLocal12=&amp;scCurTabCat=&amp;scSelTabCat=&amp;scSelLink=&amp;scGSName=&amp;scGSOptn=" + URLEncoder.encode("1") + "&amp;scSelState=&amp;scSelRow=" + URLEncoder.encode("2G1WB58K381263163") + "&amp;scSortOrder=&amp;scPageNo=" + URLEncoder.encode("1") + "&amp;WEBPCMTRANSID=" + URLEncoder.encode("0690484,2970121");

        //System.out.println( msg3 );

        int startIdx = resp2.indexOf("var tab=");
        int endIdx = resp2.indexOf("bldTr();");
       
        String dataBlock = resp2.substring(startIdx,endIdx).replaceAll(Pattern.quote("["),"").replaceAll(Pattern.quote("];"),"");
        dataBlock = dataBlock.replaceAll("var tab=\"","");
        dataBlock = dataBlock.replaceAll("  "," "); 
	//System.out.println( dataBlock );
        String[] dataBlockPieces = dataBlock.split("\", \"");

        ArrayList<String> resultsContentStrings = new ArrayList<String>();
        ArrayList<String> urlIdList = new ArrayList<String>();

        for ( int i=0; i<dataBlockPieces.length; i+=12 ) {
	  String content = "";
	  for ( int j=0; j<12; j++ ) {
	    content += dataBlockPieces[i+j] + " ";
	  }
	  resultsContentStrings.add( content );
          urlIdList.add( dataBlockPieces[i+1] );
        }
 
        ArrayList<String> msgs = new ArrayList<String>();

        for ( String urlId : urlIdList ) {
	    msgs.add( "scParam=" + URLEncoder.encode( scParam ) + "&amp;scStoreLocal1=" + URLEncoder.encode( scStoreLocal1 ) + "&amp;scStoreLocal2=" + URLEncoder.encode( scStoreLocal2 ) + "&amp;scStoreLocal3=" + URLEncoder.encode( scStoreLocal3 ) + "&amp;scStoreLocal4=&amp;scStoreLocal5=" + URLEncoder.encode( scStoreLocal5 ) + "&amp;scStoreLocal6=&amp;scStoreLocal7=&amp;scStoreLocal8=&amp;scStoreLocal9=&amp;scStoreLocal10=&amp;scStoreLocal11=&amp;scStoreLocal12=&amp;scCurTabCat=&amp;scSelTabCat=&amp;scSelLink=&amp;scGSName=&amp;scGSOptn=" + URLEncoder.encode("1") + "&amp;scSelState=&amp;scSelRow=" + URLEncoder.encode( urlId ) + "&amp;scSortOrder=&amp;scPageNo=" + URLEncoder.encode("1") + "&amp;WEBPCMTRANSID=" + URLEncoder.encode("0690484,2970121") );
        }

        ArrayList<String> urlList = new ArrayList<String>();

        for ( String msg1 : msgs ) {
	  urlList.add( "javascript:jQuery.post( &amp;quot;http://www.govsales.gov/fassys/fassrchlist/&amp;quot;, &amp;quot;" + msg1 + "&amp;quot; )" ); 
        }

        for ( int i=0; i<resultsContentStrings.size()-1; i++ ) {
          try {	
	      stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.govsales.gov/', '" + urlList.get(i) + "', '" + resultsContentStrings.get(i) + "' )" ); 
          } catch ( SQLException sqle ) { sqle.printStackTrace(); }
        }

      } catch ( IOException ioe ) { ioe.printStackTrace(); }

    }

    public static void LonestarOnline() {   
       String msg = "search_type=title_search&amp;search_name=Title+%26+Description+Search&amp;search_text=" + searchString + "&amp;phrase_match=any&amp;category=-1&amp;search_span=title&amp;search_limit=active&amp;order_by=title&amp;sort_order=ASC";
 
       try {
         URL theUrl = new URL( "http://www.lonestaronline.com/search/search_results.cfm?" + msg );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(theUrl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	    resp += line;
         }
         reader.close();

         int startIdx = resp.indexOf("<table border=0 cellspacing=0 cellpadding=2 noshade width=780>");
         int endIdx = resp.indexOf("<form name=\"blah\"");
         if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
	     //System.out.println( startIdx + " " + endIdx );

            Parser psr = new Parser();
            try {
		//System.out.println( resp.substring( startIdx, endIdx ) );
              psr.setInputHTML( resp.substring(startIdx,endIdx) );   
              NodeList nList = psr.parse(null);
              
              for ( int i=0; i<nList.size(); i++ ) {
		if ( nList.elementAt(i).getText().equals("table border=0 cellspacing=0 cellpadding=2 noshade width=780") ) {
		   NodeList trList =  nList.elementAt(i).getChildren();
                   for ( int j=0; j<trList.size(); j++ ) {
		     if ( trList.elementAt(j).getText().startsWith("tr") ) {
			String resultsContent = trList.elementAt(j).toPlainTextString();
                        resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                        resultsContent = resultsContent.replaceAll("\n","");
                        resultsContent = resultsContent.replaceAll("\t","");
                        resultsContent = resultsContent.replaceAll("\"","");
                        resultsContent = resultsContent.replaceAll("'","");
                        while ( resultsContent.contains("  ") ) {
		          resultsContent = resultsContent.replaceAll("  "," ");
                        }
                        NodeList tdList = trList.elementAt(j).getChildren();
                        for ( int k=0; k<tdList.size(); k++ ) {
			   if ( tdList.elementAt(k).getText().equals("td width=\"496\"") ) {
			       String tdContent = tdList.elementAt(k).toHtml();
                               String[] pieces = tdContent.split("href=\"");
                               if ( pieces.length > 1 ) {
				  String[] piecesII = pieces[1].split("\"");
                                  String anchorHref = "http://www.lonestaronline.com" + piecesII[0].trim();
				  try {	
	                            stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.lonestaronline.com', '" + anchorHref + "', '" + resultsContent + "' )" ); 
                                  } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                               }   
                           }   
                        }
                     }  
                   }  
                }  
              }
            } catch ( ParserException pe ) { pe.printStackTrace(); }
         }
       } catch ( IOException ioe ) { ioe.printStackTrace(); }
    }

    public static void GovDeals() {
      String msg = "";
      if ( searchState.equals("ALL") ) {    
         msg = "fa=Main.AdvSearchResults&amp;timing1=&amp;mystate=&amp;myseller=0&amp;myselectbox=00&amp;desc=" + searchString + "&amp;inv_nbr=";
      }
      else {
	  msg = "fa=Main.AdvSearchResults&amp;timing1=&amp;mystate=" + searchState + "&amp;myseller=0&amp;myselectbox=00&amp;desc=" + searchString + "&amp;inv_nbr=";
      }  

       try {
         URL ubl = new URL( "http://www.govdeals.com/index.cfm?" + msg );
         String resp = "";        
         BufferedReader reader = new BufferedReader(new InputStreamReader(ubl.openStream()));
         String line;
         while ((line = reader.readLine()) != null) {
	    resp += line;
         }
         reader.close();

         int startIdx = resp.indexOf("<tr bgcolor=\"#CCCCCC\">");
         int endIdx = resp.indexOf("<td colspan=\"9\" style=\"border-bottom:none\" scope=\"row\">");

         if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
	     // System.out.println( startIdx + " " + endIdx );
           Parser prse = new Parser();
           try {
	      prse.setInputHTML( resp.substring( startIdx, endIdx ) );
              NodeList nList = prse.parse(null);
              for ( int i=0; i<nList.size(); i++ ) { 
		 if ( nList.elementAt(i).getText().startsWith("tr valign=\"top\"") ) {
		   String resultsContent = nList.elementAt(i).toPlainTextString();
                   resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                   resultsContent = resultsContent.replaceAll("\n","");
                   resultsContent = resultsContent.replaceAll("\t","");
                   resultsContent = resultsContent.replaceAll("\"","");
                   resultsContent = resultsContent.replaceAll("'","");
                   resultsContent = resultsContent.replaceAll("View by same:CategoryLocationMake/BrandModelProximity-------------Terms &amp; ConditionsView this Item","");
                   while ( resultsContent.contains("  ") ) {
		      resultsContent = resultsContent.replaceAll("  "," ");
                   }
                   resultsContent = resultsContent.replaceAll("0Bids","0 Bids");
                   //System.out.println( resultsContent );
                   NodeList tdList = nList.elementAt(i).getChildren();
                   for ( int j=0; j<tdList.size(); j++ ) {
		     if ( tdList.elementAt(j).getText().equals("td valign=\"top\" nowrap=\"nowrap\"") ) {
		      String[] pieces = tdList.elementAt(j).toHtml().split("href=\"");
                      if ( pieces.length > 1 ) {
			String[] piecesII = pieces[1].split("\"");
                        String anchorHref = "http://www.govdeals.com/" + piecesII[0];
                        try {	
	                   stmt.executeUpdate( "INSERT INTO auction_records VALUES ( 'http://www.govdeals.com/', '" + anchorHref + "', '" + resultsContent + "' )" ); 
                        } catch ( SQLException sqle ) { sqle.printStackTrace(); }
                      }
                     }   
                   }                        
                 }
              }
           } catch ( ParserException pe ) { pe.printStackTrace(); }
         }
       } catch ( IOException ioe ) { ioe.printStackTrace(); }    
    }

    public static void IllinoisIbid() {
      String msg = "search=1&amp;catid=&amp;SearchStr=" + searchString + "&amp;AllAnyExact=all&amp;Region1=&amp;Region2=&amp;Region3=&amp;Region4=&amp;customs_criteria=1&amp;cfs_txt_EqNum=&amp;cfs_txt_VIN=&amp;cfs_int_min_Odometer=&amp;cfs_int_max_Odometer=&amp;cfs_txt_make=&amp;cfs_txt_model=&amp;cfs_txt_modelyear=&amp;PriceFrom=&amp;PriceTo=&amp;StartFrom=&amp;StartTo=&amp;EndFrom=&amp;EndTo=&amp;ExcludeStr=&amp;OrderBy=end_asc&amp;MaxResults=50&amp;sbmtAdvSearch=Go#results";    
      try {
       URL ubl = new URL( "http://ibid.illinois.gov/advancedsearch.asp?" + msg );
       String resp = "";
       BufferedReader lecteur = new BufferedReader(new InputStreamReader(ubl.openStream()));
       String line;
       while ((line = lecteur.readLine()) != null) {
          resp += line;
       }
       lecteur.close();

       int startIdx = resp.indexOf( "<div id=\"SearchResults\">");
       int endIdx = resp.indexOf( "<div id=\"PageLinksS\">" );       
       //System.out.println( startIdx + " " + endIdx ); 
       if ( startIdx > 0 &amp;&amp; endIdx > startIdx ) {
	 Parser prs = new Parser();
         try { 
	   prs.setInputHTML( resp.substring(startIdx,endIdx) );
           NodeList nList = prs.parse(null);

           for ( int i=0; i<nList.size(); i++ ) {
	      if ( nList.elementAt(i).getText().equals("div id=\"SearchResults\"") ) {
		 NodeList tblList = nList.elementAt(i).getChildren();
                 for ( int j=0; j<tblList.size(); j++ ) {
		    if ( tblList.elementAt(j).getText().equals("table cellpadding=\"2\" cellspacing=\"1\"") ) {
		      NodeList trList = tblList.elementAt(j).getChildren();
                      for ( int k=0; k<trList.size(); k++ ) {
			if ( trList.elementAt(k).getText().startsWith("tr class=\"Color") ) {
			  String resultsContent = trList.elementAt(k).toPlainTextString();
                          resultsContent = resultsContent.replaceAll("&amp;nbsp;","");
                          resultsContent = resultsContent.replaceAll("\n","");
                          resultsContent = resultsContent.replaceAll("\t","");
                          resultsContent = resultsContent.replaceAll("\"","");
                          resultsContent = resultsContent.replaceAll("'","");
                          r

Version 15 of the Government auctions scraping programs. This code scrapes from 17 different government auctions websites and aggregates those data into an SQL database.

/Sudoku (Sudoku.java) ( Java)

package org.example.sudoku;

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.util.Log;

public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Set up click listeners for all the buttons
        View continueButton = findViewById(R.id.continue_button);
        continueButton.setOnClickListener(this);
        View newButton = findViewById(R.id.new_button);
        newButton.setOnClickListener(this);
        View aboutButton = findViewById(R.id.about_button);
        aboutButton.setOnClickListener(this);
        View exitButton = findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
    }
    
    public void onClick(View v) {
    	switch(v.getId()) {
    	case R.id.about_button:
    		Intent i = new Intent(this, About.class);
    		startActivity(i);
    		break;
    	case R.id.new_button:
    		openNewGameDialog();
    		break;
    	case R.id.exit_button:
    		finish();
    		break;
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	super.onCreateOptionsMenu(menu);
    	MenuInflater inflater = getMenuInflater();
    	inflater.inflate(R.menu.menu, menu);
    	return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	switch (item.getItemId()) {
    	case R.id.settings:
    		startActivity(new Intent(this, Prefs.class));
    		return true;
    	}
    	return false;
    }

    private static final String TAG = "Sudoku";
    
    /** Ask the user what difficulty level they want */
    private void openNewGameDialog() {
    	new AlertDialog.Builder(this)
    	      .setTitle(R.string.new_game_title)
    	      .setItems(R.array.difficulty, 
    	    		    new DialogInterface.OnClickListener() {
    	    	            public void onClick(DialogInterface dialoginterface,
    	    	            		        int i) {
    	    	            	startGame(i);
    	    	            }
    	      })
    	      .show();
    }
    
    /** Start a new game with the given difficulty level */
    private void startGame(int i) {
    	Log.d(TAG, "clicked on " + i);
    	Intent intent = new Intent(Sudoku.this, Game.class);
    	intent.putExtra(Game.KEY_DIFFICULTY, i);
    	startActivity(intent);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Music.play(this, R.raw.main);
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        Music.stop(this);
    }
}

from "Hello Android 2nd Edition" (ISBN: 1-934356-49-2)

Hyper/Generic Menu creation class ( C++)

#ifndef TEXT_CONTROL_H
#define TEXT_CONTROL_H

#include &lt;iostream&gt;
#include &lt;stdarg.h&gt; /* Required for va_list */
#include &lt;windows.h&gt;
#include &lt;winable.h&gt; /* Dev-C++ specific */
#include &lt;vector&gt;

/* These are the basic 16 colors of DOS: x8 low-contrast, x8 high-contrast */
enum {
    BLACK       = 0,
    DARK_BLUE   = 1,
    DARK_GREEN  = 2,
    TEAL        = 3,
    DARK_RED    = 4,
    DARK_PURPLE = 5,
    GOLD        = 6,
    GREY        = 7,
    DARK_WHITE  = 8,
    BLUE        = 9,
    GREEN       = 10,
    CYAN        = 11,
    RED         = 12,
    PURPLE      = 13,
    YELLOW      = 14,
    WHITE       = 15
};

/* This is for emulating mouse clicks */
void Click(const int X, const int Y, const int MouseButton) {

    INPUT Input[2];
    ZeroMemory(Input, sizeof(INPUT) * 2);
    Input[0].type = INPUT_MOUSE;
    if (MouseButton == 0) { Input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN; }
    if (MouseButton == 1) { Input[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; }

    Input[1].type = INPUT_MOUSE;
    if (MouseButton == 0) { Input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP; }
    if (MouseButton == 1) { Input[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP; }

    SetCursorPos(X, Y);
    SendInput(2, Input, sizeof(INPUT));

    return;
}

/* This is to emulate a string of keys being pressed */
void SendKey(const char vkKey[], const int Delay) {

    for (int x = 0; x &lt; strlen(vkKey); x++) {

        /* If they typed a lower-case letter */
        if (isupper(vkKey[x]) &amp;&amp; isalpha(vkKey[x])) {
            keybd_event(VK_SHIFT, VkKeyScan(VK_SHIFT), 0, 0);
            keybd_event(toupper(vkKey[x]), VkKeyScan(toupper(vkKey[x])), 0, 0);
            Sleep(Delay);
            keybd_event(toupper(vkKey[x]), VkKeyScan(toupper(vkKey[x])), KEYEVENTF_KEYUP, 0);
            keybd_event(VK_SHIFT, VkKeyScan(VK_SHIFT), KEYEVENTF_KEYUP, 0);

        /* If they typed an upper-case letter */
        } else if (!ispunct(vkKey[x])) {
            keybd_event(toupper(vkKey[x]), VkKeyScan(toupper(vkKey[x])), 0, 0);
            Sleep(Delay);
            keybd_event(toupper(vkKey[x]), VkKeyScan(toupper(vkKey[x])), KEYEVENTF_KEYUP, 0);

        /* If they typed an exclaimation point (specifically) */
        } else if (ispunct(vkKey[x])) {
            if (vkKey[x] == '!') {
                keybd_event(VK_SHIFT, VkKeyScan(VK_SHIFT), 0, 0);
                keybd_event(0x31, VkKeyScan(0x31), 0, 0);
                Sleep(Delay);
                keybd_event(0x31, VkKeyScan(0x31), KEYEVENTF_KEYUP, 0);
                keybd_event(VK_SHIFT, VkKeyScan(VK_SHIFT), KEYEVENTF_KEYUP, 0);
            }
        }
    }

    return;
}

/* This is to emulate a SINGLE key being pressed */
void SendKey(const BYTE vk) {

    INPUT Input;
    ZeroMemory(&amp;Input, sizeof(Input));
    Input.type = INPUT_KEYBOARD;
    Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
    Input.ki.wVk = vk;
    SendInput(1, &amp;Input, sizeof(INPUT));

    return;
}

/* This is to remove the blinking caret (in the console (DOS)) */
void RemoveCursor() {

    /* Remove the cursor (does not work in full screen) */
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO CursoInfo;
    CursoInfo.dwSize = 1;         /* The size of caret */
    CursoInfo.bVisible = false;   /* Caret is visible? */
    SetConsoleCursorInfo(hConsole, &amp;CursoInfo);

    return;
}

/* This is to add the blinking caret (in the console (DOS)) */
void AddCursor() {

    /* Remove the cursor (does not work in full screen) */
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO CursoInfo;
    CursoInfo.dwSize = 10;        /* The size of caret */
    CursoInfo.bVisible = true;   /* Caret is visible? */
    SetConsoleCursorInfo(hConsole, &amp;CursoInfo);

    return;
}

/* This changes ONLY the foreground (the text) color */
void SetColor(const int foreground) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, foreground);

    return;
}

/* This changes the foreground (text) and background (behind the text) color */
void SetColor(const int foreground, const int background) {

    int Color = foreground + (background * 16);
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, Color);

    return;
}

/* This is to turn the console 100% black typically (foreground and background) */
void ClearConsole(const int foreground, const int background) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    COORD coordScreen = { 0, 0 };
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    DWORD dwConSize;

    if (!GetConsoleScreenBufferInfo(hConsole, &amp;csbi)) { return; }
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    SetColor(foreground, background);
    if (!FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &amp;cCharsWritten)) { return; }
    if (!GetConsoleScreenBufferInfo(hConsole, &amp;csbi)) { return; }
    if (!FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &amp;cCharsWritten)) { return; }

    return;
}

/* This moves where the caret draws (so you can jump around) */
void PlaceCursor(const int x, const int y) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    COORD PlaceCursorHere;
    PlaceCursorHere.X = x;
    PlaceCursorHere.Y = y;

    SetConsoleCursorPosition(hConsole, PlaceCursorHere);
    return;
}

/* This is called "printfExt" or printfExtension; It's an unfinished project */
void printfExt(const char *Text, ...) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    va_list argptr;
    va_start(argptr, Text);

    while (*Text != '\0') {

        /* % is a token */
        if (*Text == '%') {
            *Text++;

            /* Change color */
            if (*Text == 'c') {
                int color = va_arg(argptr, int);
                SetConsoleTextAttribute(hConsole, color);
            }

            /* Move cursor position */
            if (*Text == 'p') {
                COORD MoveCursor = va_arg(argptr, COORD);
                SetConsoleCursorPosition(hConsole, MoveCursor);
            }

            /* Display an integer */
            if (*Text == 'i') {
                char convert[1] = {'\0'};
                int Number = va_arg(argptr, int);

                itoa(Number, convert, 10);
                WriteConsole(hConsole, convert, strlen(convert), 0, NULL);
            }

            /* Display a string of characters */
            if (*Text == 's') {
                char* String = va_arg(argptr, char *);
                WriteConsole(hConsole, String, strlen(String), 0, NULL);
            }
        } else { WriteConsole(hConsole, Text, 1, 0, NULL); }

        *Text++;
    }

    va_end(argptr);
}

/* This is to place text at a specific location (obsolete now) */
void PlaceText(const char *Text, const int x, const int y) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    COORD PlaceCursorHere;
    PlaceCursorHere.X = x;
    PlaceCursorHere.Y = y;

    SetConsoleCursorPosition(hConsole, PlaceCursorHere);

    WriteConsole(hConsole, Text, strlen(Text), 0, NULL);
    return;
}

/* This draws a box - nothing special, but quite handy */
void DrawBox(const int Width, const int Height, const int PlaceX, const int PlaceY) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    /* Horizontal lines */
    for (int x = 0; x &lt; Height; x++) { PlaceCursor(PlaceX, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
    for (int x = 0; x &lt; Height; x++) { PlaceCursor(PlaceX + Width - 1, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }

    /* Vertical lines */
    for (int x = 0; x &lt; Width; x++) { PlaceCursor(PlaceX + x, PlaceY); WriteConsole(hConsole, "Í", 1, 0, NULL); }
    for (int x = 0; x &lt; Width; x++) { PlaceCursor(PlaceX + x, PlaceY + Height - 1); WriteConsole(hConsole, "Í", 1, 0, NULL); }

    PlaceCursor(PlaceX, PlaceY); WriteConsole(hConsole, "É", 1, 0, NULL);                          /* Upper left corner   */
    PlaceCursor(PlaceX + Width - 1, PlaceY); WriteConsole(hConsole, "»", 1, 0, NULL);              /* Upper right corner  */
    PlaceCursor(PlaceX, PlaceY + Height - 1); WriteConsole(hConsole, "È", 1, 0, NULL);             /* Bottom left corner  */
    PlaceCursor(PlaceX + Width - 1, PlaceY + Height - 1); WriteConsole(hConsole, "¼", 1, 0, NULL); /* Bottom right corner */

    return;
}

/* This draws a box with a specificed foreground color - nothing special, but quite handy */
void DrawBox(const int Color, const int Width, const int Height, const int PlaceX, const int PlaceY) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, Color);

    /* Horizontal lines */
    for (int x = 0; x &lt; Height; x++) { PlaceCursor(PlaceX, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
    for (int x = 0; x &lt; Height; x++) { PlaceCursor(PlaceX + Width - 1, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }

    /* Vertical lines */
    for (int x = 0; x &lt; Width; x++) { PlaceCursor(PlaceX + x, PlaceY); WriteConsole(hConsole, "Í", 1, 0, NULL); }
    for (int x = 0; x &lt; Width; x++) { PlaceCursor(PlaceX + x, PlaceY + Height - 1); WriteConsole(hConsole, "Í", 1, 0, NULL); }

    PlaceCursor(PlaceX, PlaceY); WriteConsole(hConsole, "É", 1, 0, NULL);                          /* Upper left corner   */
    PlaceCursor(PlaceX + Width - 1, PlaceY); WriteConsole(hConsole, "»", 1, 0, NULL);              /* Upper right corner  */
    PlaceCursor(PlaceX, PlaceY + Height - 1); WriteConsole(hConsole, "È", 1, 0, NULL);             /* Bottom left corner  */
    PlaceCursor(PlaceX + Width - 1, PlaceY + Height - 1); WriteConsole(hConsole, "¼", 1, 0, NULL); /* Bottom right corner */

    return;
}

/* This fills IN a box (the inverse of DrawBox) */
void FillBox(const int Width, const int Height, const int PlaceX, const int PlaceY, const char FillBlock) {

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    for (int y = 0; y &lt; Height; y++) {
        PlaceCursor(PlaceX, PlaceY + y);
        for (int x = 0; x &lt; Width; x++) {
            WriteConsole(hConsole, &amp;FillBlock, 1, 0, NULL);
        }
    }

    return;
}

/* This is to enable debug privileges, handy for when you use ReadProcessMemory on games */
bool EnableSEPriv()  {

    HANDLE hToken;
    LUID luID;
    TOKEN_PRIVILEGES tkp;

    if (!OpenProcessToken(GetCurrentProcess(), (TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY), &amp;hToken)) { return FALSE; }
    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &amp;luID)) { return FALSE; }

    tkp.PrivilegeCount = 1;
    tkp.Privileges[0].Luid = luID;
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

    AdjustTokenPrivileges(hToken, FALSE, &amp;tkp, sizeof(tkp), NULL, NULL);
    CloseHandle(hToken);

    return TRUE;
}

/* Please note that this class is ever-changing as I get more ideas */
class CREATE_MENU {

    private:
        std::vector&lt;std::string&gt; Options; /* The options held */
        int MaxItems, Arrow, CurrItem;    /* Maximum menu items, where the arrow is at, and the current item selected */
        int Width, Height, X, Y;          /* Width, Height, X-coordinate, Y-coordinate of the menu */
        char *Label;                      /* The label atop the menu */
        COORD MoveTo;                     /* X, Y coordinates for the arrow (printfExt is unfinished and can only use COORD type) */

        /* In the callback, the "Exit key"  is the base-10 value: 0       */
        /* In the callback, the "Enter key" is the base-10 value: 5       */
        /* In the callback, the "Right key" is the base-10 value: 10      */
        /* In the callback, the "Left key"  is the base-10 value: 15      */
        bool EnterHit;                    /* Was the return key hit?      */
        bool ExitHit;                     /* Was the exit key hit?        */
        bool RightKeyHit;                 /* Was the right arrow key hit? */
        bool LeftKeyHit;                  /* Was the left arrow key hit?  */

        /* Duplicate values to store an off-screen menu */
        int xWidth, xHeight, xX, xY;
        int xMaxItems, xArrow, xCurrItem;
        char *xLabel;
        std::vector&lt;std::string&gt; xOptions;
        COORD xMoveTo;

    public:

        /* The constructor sets everything to null basically */
        CREATE_MENU();

        /* To clear the last menu generated */
        void Clear(const int foreground, const int background);

        /* To store a menu that is currently being displayed */
        void Store();

        /* To restore a menu that's held "offscreen" */
        void Restore(const int foreground, const int background);

        /* Set the width, height, X-coordinate, Y-coordinate, and label (at the top) of a menu */
        void SetAttributes(const int uWidth, const int uHeight, const int uPlaceX, const int uPlaceY, char* uLabel);

        /* The number of menu items shown, and then the arguments you want to add */
        void AddOptions(int arguments, ...);

        /* To display the menu */
        void DisplayMenu(const int foreground, const int background);

        /* To loop the function to a callback that takes a: CurrItem, ExitMenu, and KeyPressed */
        void Loop(int (*callback)(int, bool, int), bool ExitMenu);

        /* To change where the arrow is pointing (seldom used) */
        void SetArrow(const int NewPos) { PlaceCursor(MoveTo.X, MoveTo.Y); printf("  "); MoveTo.Y = NewPos; }

        /* Used to move the pointing arrow smoothly (thanks to JackOfAllTrades!) */
        void KeyEventProc(KEY_EVENT_RECORD ker);
};

CREATE_MENU::CREATE_MENU() {

    EnterHit = false;
    ExitHit = false;
    RightKeyHit = false;
    LeftKeyHit = false;
    Width = 5;
    Height = 5;
    X = 0;
    Y = 0;
    MaxItems = 1;
    Arrow = 0;
    CurrItem = 0;
    Label = "";
    MoveTo.X = X + 3;
    MoveTo.Y = Arrow;
    if (!Options.empty()) { Options.clear(); }

    xWidth = 0;
    xHeight = 0;
    xX = 0;
    xY = 0;
    xMaxItems = 0;
    xArrow = 0;
    xCurrItem = 0;
    xLabel = "";
    xMoveTo.X = 0;
    xMoveTo.Y = 0;
    if (!xOptions.empty()) { xOptions.clear(); }
}

void CREATE_MENU::Clear(const int foreground, const int background) {

    SetColor(BLACK, BLACK);
    FillBox(Width, Height + 1, X, Y - 1, ' ');
    SetColor(foreground, background);

    return;
}

void CREATE_MENU::Store() {

    xWidth = Width;
    xHeight = Height;
    xX = X;
    xY = Y;
    xMaxItems = MaxItems;
    xArrow = Arrow;
    xCurrItem = CurrItem;
    xLabel = Label;
    xMoveTo.X = MoveTo.X;
    xMoveTo.Y = MoveTo.Y;

    /* We don't want trash values, so we empty it first */
    if (!xOptions.empty()) { xOptions.clear(); }
    for (int x = 0; x &lt; Options.size(); x++) { xOptions.push_back(Options.at(x)); }

    return;
}

void CREATE_MENU::Restore(const int foreground, const int background) {

    Width = xWidth;
    Height = xHeight;
    X = xX;
    Y = xY;
    MaxItems = xMaxItems;
    Arrow = xArrow;
    CurrItem = xCurrItem;
    Label = xLabel;
    MoveTo.X = xMoveTo.X;
    MoveTo.Y = xMoveTo.Y;
    if (!Options.empty()) { Options.clear(); }
    for (int x = 0; x &lt; xOptions.size(); x++) { Options.push_back(xOptions.at(x)); }

    /* So you don't have to explicity call upon DisplayMenu right after Restore, we call it here */
    DisplayMenu(foreground, background);

    return;
}

void CREATE_MENU::SetAttributes(const int uWidth, const int uHeight, const int uPlaceX, const int uPlaceY, char* uLabel) {

    Width  = uWidth;
    Height = uHeight;
    X = uPlaceX;
    Y = uPlaceY;
    Label  = uLabel;
    MoveTo.X = X + 3;

    return;
}

void CREATE_MENU::AddOptions(int arguments, ...) {

    /* This adjusts the arrows position so it's 3 below the top of the menu */
    Arrow = (Y + 3);
    MoveTo.Y = Arrow;
    MaxItems = (arguments + Y + 2);

    va_list argptr;
    va_start(argptr, arguments);

    if (!Options.empty()) { Options.clear(); }
    for (int y = Y; arguments != 0; y++) {
        char *s = va_arg(argptr, char *);
        Options.push_back(s);
        arguments--;
    }

    va_end(argptr);

    return;
}

void CREATE_MENU::DisplayMenu(const int foreground, const int background) {

    /* Fill in the area we're about to draw on */
    SetColor(BLACK, BLACK);
    FillBox(Width + 1, Height + 1, X - 1, Y - 1, ' ');

    /* Change the color and draw the menu's box */
    SetColor(foreground, background);
    DrawBox(Width, Height, X, Y);

    /* Center the text */
    int Temp = ((Width / 2) + X - 2) - (strlen(Label) / 2);
    SetColor(background, foreground);
    PlaceCursor(Temp, Y); printf("  %s  ", Label);

    /* Place the text */
    SetColor(foreground, background);
    DrawBox(strlen(Label) + 8, 3, Temp - 2, Y - 1);

    /* Place the "railroad crossing" ASCII characters */
    PlaceCursor(Temp - 2, Y); printf("Î");
    PlaceCursor(Temp + 5 + strlen(Label), Y); printf("Î");

    /* Display the actual menu items ascendingly */
    SetColor(WHITE, BLACK);
    for (int x = 0; x &lt; Options.size(); x++) {
        PlaceCursor(X + 6, Y + x + 3);
        std::cout &lt;&lt; Options.at(x);
    }

    /* Draw our arrow */
    printfExt("%p%c-&gt;", MoveTo, WHITE);

    return;
}

void CREATE_MENU::Loop(int (*callback)(int, bool, int), bool ExitMenu) {

    HANDLE hStdin;
    DWORD cNumRead, fdwMode, fdwSaveOldMode, i;
    INPUT_RECORD irInBuf[128];

    hStdin = GetStdHandle(STD_INPUT_HANDLE);
    GetConsoleMode(hStdin, &amp;fdwSaveOldMode);

    while (!ExitMenu) {

        ReadConsoleInput(hStdin, irInBuf, 128, &amp;cNumRead);

        for (i = 0; i &lt; cNumRead; i++) {
            switch (irInBuf[i].EventType) {
                case KEY_EVENT: {
                    KeyEventProc(irInBuf[i].Event.KeyEvent);
                    if (EnterHit) {
                        EnterHit = false;            /* Reset state */
                        CurrItem = MoveTo.Y - Y - 3; /* The menu item they selected */
                        if (callback(CurrItem, ExitMenu, 5)) { ExitMenu = true; }
                    }

                    if (RightKeyHit) {
                        RightKeyHit = false;         /* Reset state */
                        CurrItem = MoveTo.Y - Y - 3; /* The menu item they selected */
                        if (callback(CurrItem, ExitMenu, 10)) { ExitMenu = true; }
                    }

                    if (LeftKeyHit) {
                        LeftKeyHit = false;          /* Reset state */
                        CurrItem = MoveTo.Y - Y - 3; /* The menu item they selected */
                        if (callback(CurrItem, ExitMenu, 15)) { ExitMenu = true; }
                    }

                    if (ExitHit) {
                        ExitHit = false; /* Reset state */
                        CurrItem = 666;  /* Used in a switch: if CurrItem is 666 -&gt; ExitMenu = true */
                        if (callback(CurrItem, ExitMenu, 0)) { ExitMenu = true; }
                    }
                }
            }
        }
    }

    return;
}

void CREATE_MENU::KeyEventProc(KEY_EVENT_RECORD ker) {

    MoveTo.X = X + 3;

    /* Move the arrow down; But no further than the menu items go */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_UP &amp;&amp; Y + 3 &lt; MoveTo.Y) {
        printfExt("%p%c  ", MoveTo, BLACK);
        MoveTo.Y--;
        printfExt("%p%c-&gt;", MoveTo, WHITE);
    } else { }

    /* Move the arrow up; But no further than the menu items go */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_DOWN &amp;&amp; MoveTo.Y &lt; MaxItems) {
        printfExt("%p%c  ", MoveTo, BLACK);
        MoveTo.Y++;
        printfExt("%p%c-&gt;", MoveTo, WHITE);
    } else { }

    /* If the user pressed their return key, change the state of "EnterHit" */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_RETURN) { EnterHit = true; } else { }

    /* If the user pressed their escape key, change the state of "ExitHit" */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_ESCAPE) { ExitHit = true; } else { }

    /* If the user pressed their right key, change the state of "RightKeyHit" */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_RIGHT) { RightKeyHit = true; } else { }

    /* If the user pressed their right key, change the state of "LeftKeyHit" */
    if (ker.bKeyDown &amp;&amp; ker.wVirtualKeyCode == VK_LEFT) { LeftKeyHit = true; } else { }

    return;
}

#endif
/**** End of TextControl.h ****/
/******************************/

/* A [b]full and complete example[/b] of practical usage - Please note there are [b]multiple[/b] ways of going about this */
/* SOURCE CODE BEGINS - main.cpp */
/*********************************/

#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;TextControl.h&gt; /* This is what I call mine, and I put it in the "...\Dev-Cpp\include" directory */
using namespace std;

CREATE_MENU Menu; /* Generally global variables are "bad" but in this case, it's a must-have OR you're going to be passing it around alot */
vector&lt;string&gt; Employee;
vector&lt;int&gt; EmployeeID;

/* Iterators to remove specific values */
vector&lt;string&gt;::iterator Employee_Iterator;
vector&lt;int&gt;::iterator EmployeeID_Iterator;

/* Prototypes make it alot easier */
int Main_Callback(int, bool, int);
void DisplayMainMenu();

/* Non-menu related prototypes */
void DisplayAllEmployees();
void AddAnEmployee();
void RemoveAnEmployee();

/* In the callback (a programmers "custom defined function (and name)"), we handle any events to 'that' menu */
/* The keys (that I personally made, you can easily add/edit) detectable are: Enter, Right, Left, and Escape */
/* Their (base-10) values are (ascending order): 5, 10, 15, and 666: the exit key :) */
int Main_Callback(int CurrItem, bool ExitMenu, int Key) {

    /* CurrItem - The item that the arrow is on */
    /* ExitMenu - Whether or not we exit the menu (think of it as a nested loop of menus) */
    /* Key - The key detected */

    switch (CurrItem) {
        case 0: { if (Key == 5) { DisplayAllEmployees(); } } break;
        case 1: { /* Why should I have to code this? :( */ } break;
        case 2: { if (Key == 5) { AddAnEmployee(); } } break;
        case 3: { if (Key == 5) { RemoveAnEmployee(); } } break;
        case 4: ExitMenu = true; break;
        case 666: ExitMenu = true; break;
    }

    /* ExitMenu will (by default) return false - meaning it will iterate again */
    /* If ExitMenu does return true, however, it will exit that loop (thus terminating that "menu") */
    return ExitMenu;
}

/* You don't have to use a function like this, but from personal experience, it makes it MUCH easier to manage */
/* Also, I'd personally split up functions into header files (easier to manage), but for this demonstration, they're all piled into main */
void DisplayMainMenu() {

    Menu.SetAttributes(30, 15, 20, 5, "EMPLOYEE MANAGER");
    Menu.AddOptions(5, "Show all employees", "Show an employee", "Add an employee", "Remove an employee", "Quit");
    Menu.DisplayMenu(CYAN, BLACK);
    Menu.Loop(Main_Callback, false);
    return;
}

void DisplayAllEmployees() {

    /* We want to temporarily remove the menu from our screen so we can do other business */
    Menu.Clear(BLACK, BLACK);

    /* Now we decorate our screen with fancy designs, and bells, and whistles! */
    DrawBox(WHITE, 27, 10, 20, 5);

    PlaceCursor(20, 3);
    printf("EMPLOYEE MANAGEMENT SYSTEM");

    PlaceCursor(20, 4);
    printf("- ALL EMPLOYEES HIRED");

    PlaceCursor(22, 6);
    printf("ID# - NAME");

    for (int x = 0; x &lt; Employee.size(); x++) {
        PlaceCursor(22, 8 + x);
        cout &lt;&lt; EmployeeID.at(x) &lt;&lt; " - " &lt;&lt; Employee.at(x);
    }

    /* Wait for them to hit enter (duh) */
    cin.get();

    /* We need to clear the text we made earlier before we can continue */
    ClearConsole(BLACK, BLACK);

    /* You may call me Hudini! For I have resurrected the invisible seeming menu! */
    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

void AddAnEmployee() {

    Menu.Clear(BLACK, BLACK);

    DrawBox(WHITE, 27, 10, 20, 5);

    PlaceCursor(20, 3);
    printf("EMPLOYEE MANAGEMENT SYSTEM");

    PlaceCursor(20, 4);
    printf("- ADD AN EMPLOYEE");

    PlaceCursor(22, 6);
    printf("ID# - NAME");

    int NewID = 0;

    PlaceCursor(22, 8);
    printf("New employees ID: ");
    cin &gt;&gt; NewID;
    EmployeeID.push_back(NewID);

    string NewName;

    PlaceCursor(22, 9);
    printf("New employees name: ");
    cin &gt;&gt; NewName;
    Employee.push_back(NewName);

    cin.get();
    ClearConsole(BLACK, BLACK);
    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

void RemoveAnEmployee() {

    Menu.Clear(BLACK, BLACK);

    DrawBox(WHITE, 27, 10, 20, 5);

    PlaceCursor(20, 3);
    printf("EMPLOYEE MANAGEMENT SYSTEM");

    PlaceCursor(20, 4);
    printf("- REMOVE AN EMPLOYEE");

    PlaceCursor(22, 6);
    printf("ID# - NAME");

    int ID = 0;

    PlaceCursor(22, 8);
    printf("Employees ID (to remove): ");
    cin &gt;&gt; ID;

    string Name;

    PlaceCursor(22, 9);
    printf("Employees name (to remove): ");
    cin &gt;&gt; Name;

    for (int x = 0; x &lt; EmployeeID.size(); x++) {
        if (ID == EmployeeID.at(x) &amp;&amp; Name == Employee.at(x)) {
            Employee_Iterator = Employee.begin() + x;     /* Erase the Employee's name */
            EmployeeID_Iterator = EmployeeID.begin() + x; /* Erase the Employee's ID # */

            Employee.erase(Employee_Iterator);
            EmployeeID.erase(EmployeeID_Iterator);

            break;
        }
    }

    cin.get();
    ClearConsole(BLACK, BLACK);
    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

int main() {

    /* Clear out the entire console (if it were true DOS, there'd be all the text from previous commands) */
    ClearConsole(BLACK, BLACK);

    /* Remove the blinking caret (I find it to be ANNOYING as heck!) */
    RemoveCursor();

    /* First - Empty our Employee vector and throw some names into it! :) */
    if (!Employee.empty()) { Employee.clear(); }
    Employee.push_back("Hyper");
    Employee.push_back("JackOfAllTrades");
    Employee.push_back("Amedeus");
    Employee.push_back("skyhawk133");

    /* Second - Empty our EmployeeID vector and throw some numbers into it */
    if (!EmployeeID.empty()) { EmployeeID.clear(); }
    EmployeeID.push_back(512);
    EmployeeID.push_back(716);
    EmployeeID.push_back(404);
    EmployeeID.push_back(824);

    /* Start the rabbit hole of nested loops */
    DisplayMainMenu();

    return 0;
}

/* SOURCE CODE ENDS - ME TALKING BEGINS */
/****************************************/

I would like to state [i]again[/i], that this is only one of many ways you could put the generic class to use.
You could implement it in an entirely different way! This demonstration was for a more "business like" example.

For a more "database-like" demonstration, it includes the usage of "Store" and "Restore" along with an elaborated
example of how you could implement the class menu (more than a single callback)! Continue to read...

/* SOURCE CODE BEGINS - main.cpp */
/*********************************/
#include &lt;iostream&gt;
#include &lt;TextControl.h&gt;
using namespace std;

CREATE_MENU Menu;

int Main_Callback(int, bool, int);
void DisplayMainMenu();

void DisplayAllExamples();
void DisplayViewableExamples();
void View_Example1();
void View_Example2();
void View_Example3();
void View_Example4();

/* These don't have to be "global," could be in a class...! */
int Global_Warming = 50;
int Desert_Icestorm = 500;

int Main_Callback(int CurrItem, bool ExitMenu, int Key) {

    switch (CurrItem) {
        case 0: { if (Key == 5) { DisplayAllExamples(); } } break;
        case 1: { if (Key == 5) { DisplayViewableExamples(); } } break;
        case 2: { if (Key == 10) { Global_Warming++; PlaceCursor(39, 10); printf("%i", Global_Warming); } } break;
        case 3: { if (Key == 15) { Desert_Icestorm--; PlaceCursor(39, 11); printf("%i", Desert_Icestorm); } } break;
        case 4: ExitMenu = true; break;
        case 666: ExitMenu = true; break;
    }

    return ExitMenu;
}

int Viewable_Callback(int CurrItem, bool ExitMenu, int Key) {

    switch (CurrItem) {
        case 0: { if (Key == 5) { View_Example1(); } } break;
        case 1: { if (Key == 5) { View_Example2(); } } break;
        case 2: { if (Key == 5) { View_Example3(); } } break;
        case 3: { if (Key == 5) { View_Example4(); } } break;
        case 4: {
            if (Key == 5) {
                ExitMenu = true;
                Menu.Clear(CYAN, BLACK);
                Menu.SetAttributes(36, 15, 20, 5, "C DATABASE EXAMPLE");
                Menu.AddOptions(5, "Show a list of examples", "View an example", "Increase me: ", "Decrease me: ", "Quit");
                Menu.DisplayMenu(CYAN, BLACK);

                PlaceCursor(39, 10); printf("%i", Global_Warming);
                PlaceCursor(39, 11); printf("%i", Desert_Icestorm);
            }
        } break;

        case 666: {
            ExitMenu = true;
            Menu.Clear(CYAN, BLACK);
            Menu.SetAttributes(36, 15, 20, 5, "C DATABASE EXAMPLE");
            Menu.AddOptions(5, "Show a list of examples", "View an example", "Increase me: ", "Decrease me: ", "Quit");
            Menu.DisplayMenu(CYAN, BLACK);

            PlaceCursor(39, 10); printf("%i", Global_Warming);
            PlaceCursor(39, 11); printf("%i", Desert_Icestorm);
        } break;
    }

    return ExitMenu;
}

void DisplayMainMenu() {

    Menu.SetAttributes(36, 15, 20, 5, "C DATABASE EXAMPLE");
    Menu.AddOptions(5, "Show a list of examples", "View an example", "Increase me: ", "Decrease me: ", "Quit");
    Menu.DisplayMenu(CYAN, BLACK);

    PlaceCursor(39, 10); printf("%i", Global_Warming);
    PlaceCursor(39, 11); printf("%i", Desert_Icestorm);

    Menu.Loop(Main_Callback, false);
    return;
}

void DisplayViewableExamples() {

    Menu.SetAttributes(36, 15, 20, 5, "C DATABASE EXAMPLE");
    Menu.AddOptions(5, "printfExt", "DrawBox", "FillBox", "CREATE_MENU", "Back");
    Menu.DisplayMenu(CYAN, BLACK);
    Menu.Loop(Viewable_Callback, false);
    return;
}

void DisplayAllExamples() {

    Menu.Clear(BLACK, BLACK);

    DrawBox(WHITE, 27, 10, 20, 5);

    PlaceCursor(24, 3);
    printf("C EXAMPLE DATABASE");
    PlaceCursor(23, 4);
    printf("---  ----  ----  ---");

    PlaceCursor(23, 7);
    printf("1. printfExt");

    PlaceCursor(23, 8);
    printf("2. DrawBox");

    PlaceCursor(23, 9);
    printf("3. FillBox");

    PlaceCursor(23, 10);
    printf("4. CREATE_MENU (class)");

    cin.get();

    PlaceCursor(23, 3);
    printf("                    ");
    PlaceCursor(23, 4);
    printf("                    ");

    Menu.DisplayMenu(CYAN, BLACK);

    PlaceCursor(39, 10); printf("%i", Global_Warming);
    PlaceCursor(39, 11); printf("%i", Desert_Icestorm);
    return;
}

void View_Example1() {

    Menu.Clear(BLACK, BLACK);

    COORD Step0 = { 0, 0 };
    COORD Step1 = { 4, 1 };
    COORD Step2 = { 5, 2 };
    COORD Step3 = { 6, 3 };
    COORD Step4 = { 7, 4 };
    COORD Step5 = { 8, 5 };

    printfExt("%p%cThis %p", Step0, WHITE, Step1);
    printfExt("%cis%p", YELLOW, Step2);
    printfExt("%ca%p", PURPLE, Step3);
    printfExt("%cdemonstration%p", GREEN, Step4);
    printfExt("%cof%p", BLUE, Step5);
    printfExt("%cprintfExt", RED);

    cin.get();

    printfExt("%p       %p", Step0, Step1);
    printfExt("    %p", Step2);
    printfExt("   %p", Step3);
    printfExt("               %p", Step4);
    printfExt("    %p", Step5);
    printfExt("           ");

    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

void View_Example2() {

    Menu.Clear(BLACK, BLACK);

    int Boxes[7] = {0};
    int BoxX[7] = {0};
    int BoxY[7] = {0};

    for (int x = 0; x &lt; 7; x++) { Boxes[x] = rand() % 10 + 2; BoxX[x] = rand() % 65; BoxY[x] = rand() % 15; }
    for (int x = 0; x &lt; 7; x++) { SetColor(rand() % 15 + 1, BLACK); DrawBox(Boxes[x], Boxes[x], BoxX[x], BoxY[x]); }

    cin.get();

    for (int x = 0; x &lt; 7; x++) { DrawBox(BLACK, Boxes[x], Boxes[x], BoxX[x], BoxY[x]); }

    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

void View_Example3() {

    Menu.Clear(BLACK, BLACK);

    int Boxes[7] = {0};
    int BoxX[7] = {0};
    int BoxY[7] = {0};

    for (int x = 0; x &lt; 7; x++) { Boxes[x] = rand() % 10 + 2; BoxX[x] = rand() % 65; BoxY[x] = rand() % 15; }
    for (int x = 0; x &lt; 7; x++) { SetColor(BLACK, rand() % 15 + 1); FillBox(Boxes[x], Boxes[x], BoxX[x], BoxY[x], ' '); }

    cin.get();

    SetColor(BLACK, BLACK);
    for (int x = 0; x &lt; 7; x++) { FillBox(Boxes[x], Boxes[x], BoxX[x], BoxY[x], ' '); }

    Menu.DisplayMenu(CYAN, BLACK);
    return;
}

void View_Example4() {

    Menu.Clear(BLACK, BLACK);

    /* Now you get to see Store used! :p */
    Menu.Store();

    Menu.SetAttributes(rand() % 20 + 22, rand() % 10 + 2, rand() % 40 + 2, rand() % 10 + 2, "CREATE_MENU");
    Menu.AddOptions(5, "This", "Is", "a", "Random", "CREATE_MENU");
    Menu.DisplayMenu(rand() % 16 + 1, rand() % 16);
    
    cin.get();

    /* Don't want stray text and we can't just use Menu.clear(BLACK, BLACK) due to how it functions */
    ClearConsole(BLACK, BLACK);

    Menu.Restore(CYAN, BLACK);
    return;
}

int main() {

    ClearConsole(BLACK, BLACK);
    RemoveCursor();

    DisplayMainMenu();

    return 0;
}

Generic set of text routines: Creates Menus, changes text color, cursor position, caret blinking, drawing a box, filling a box, and mouse/keyboard emulation

luizlopes/Elegant FizzBuzz Example ( JavaScript)

var i;

for (i = 1; i <= 100; i++) {
  console.log([!(i % 3) ? 'fizz' : void 0] + [!(i % 5) ? 'buzz' : void 0] || i);
}

When you use the + operator on an Array, it converts it to a string.[].toString() is the same as [].join(','), which gives an empty string in case the array value is undefined or null. This also works in Javascript ([undefined] + "b" === "b").

dividespace/rMenu.css ( CSS)

@charset "iso-8859-1";

/*******************************************************************************
*  rMenu.css : 2006.10.17 : ruthsarian@gmail.com
* ------------------------------------------------------------------------------
* Ruthsarian Menus - A CSS-based dropdown menu system
*
* <insert long, boring ramble here>
*
* KNOWN BUGS
*	- Opera 7.23 and earlier have problems with absolutely positioned 
*	  elements positioned relative to a parent element. this causes a
*	  problem with right-aligned horizontal menus. stay away from those
*	  types of menus if you've got any reason to care about Opera 7.23 or
*	  earlier versions.
*
* DEV NOTES
*	- setting position: relative; to ul.rMenu triggers a bug in Netscape 7
*	  and earlier that makes content jump as menus pop
*	- need to remember that when assigning multiple classes to an element
*	  to list them left-to-right from most-specific to least-specific.
*	  Otherwise IE/Mac flips out
*	- IE/Mac needs whitespace before <UL> and </UL> tags in the markup
*	  otherwise very odd things can happen
*	- hasLayout should not be triggered on LI elements under IE7
*	- IE/Mac has a selector bug where rMenu-v* and rMenu-h* rules
*	  are applied to rMenu-v and rMenu-h elements. ie rMenu-vRight rules
*	  get applied to rMenu-v elements. This is incorrect.
*	- if any parent element of the menu is a float it (or the parent of
*	  the menu) needs to be relatively positioned. Otherwise the menu
*	  is not rendered on the page.
*
* EXAMPLE HTML
*	<ul class="rMenu-hor rMenu"
*	  ><li
*	    ><a href="">Menu Item</a
*	    > <ul class="rMenu-ver"
*	      ><li
*	        ><a href="">Menu Item</a
*	      ></li
*	      ><li
*	        ><a href="">Menu Item</a
*	      ></li
*	    > </ul
*	  ></li
*	  ><li
*	    ><a href="">Menu Item</a
*	  ></li
*	 > </ul>
*
* ------------------------------------------------------------------------------
*  This stylesheet is released into the public domain.
*******************************************************************************/

/*******************************************************************************
 * General Menu Mechanics
 *
 * Below is a set of rules which is applicable to any list used within
 * this dropdown menu system. You could apply just these rules and get
 * a basic dropdown menu system working just fine in FireFox, Opera,
 * Safari, and most other modern browsers.
 */
ul.rMenu, ul.rMenu ul, ul.rMenu li, ul.rMenu a
{
	display: block;		/* make these objects blocks so they're easier
				   to deal with */
	margin: 0;
	padding: 0;		/* get rid of padding/margin values that these
				   elements may have by default */
}
ul.rMenu, ul.rMenu li, ul.rMenu ul
{
	list-style: none;	/* proper browsers don't require this because
				   block elements (see previous rule set) cannot
				   take any list-style property. meaning 
				   existing list-style properties are removed
				   when they are set to display: block. IE7 
				   seems to ignore this fact under certain
				   situations so we explicitly set it here
				   even though it's, technically, incorrect 
				   CSS (but it will validate). */
}
ul.rMenu ul
{
	display: none;		/* hide the sub-menus until needed */
	position: absolute;	/* remove the sub-menus from the flow of the
				   layout so when they pop they don't cause any
				   disfiguration of the layout */
}
ul.rMenu li
{
	position: relative;	/* so sub-menus position relative to their 
				   parent LI element */
}
ul.rMenu li:hover
{
	z-index: 999;		/* make sure this and any sub-menus that pop 
				   appear above everything else on the page */
}
ul.rMenu li:hover > ul
{
	display: block;		/* show the sub-menu */
}

/*******************************************************************************
 * Extended Menu Mechanics
 *
 * These rules exist only for specific menu types, such as horizontal or
 * vertical menus, right or left aligned menus.
 */
ul.rMenu-hor li
{
	float: left;
	width: auto;
}
ul.rMenu-hRight li
{
	float: right;		/* horizontal, right menus need their LI
				   elements floated to get them over there */
}
ul.rMenu-ver li
{
	float: none;		/* clear this so vertical sub-menus that are
				   children of horizontal menus won't have
				   their LI widths set to auto. */
}
ul.rMenu-ver, ul.rMenu-ver ul
{
	width: 10em;		/* sub-menus need a defined width, especially
				   vertical sub-menus. salt to taste. */
}
ul.rMenu-wide
{
	width: auto;		/* apply this rule if you want the top-level
				   menu to go as wide as possible. this is 
				   something you might want if your top-level
				   is a vertical menu that spans the width
				   of a column which has its width 
				   pre-defined. */
}
ul.rMenu-vRight
{
	float: right;		/* use this to float a vertical menu right. */
}
ul.rMenu-lFloat
{
	float: left;		/* use this to float a vertical menu left. */
}
ul.rMenu-noFloat
{
	float: none;		/* this is to cover those cases where a menu
				   is floated by default and you have a reason
				   to not float it. such as a menu on the
				   right side of the screen that you want 
				   to have drops going left but not floated.
				   to be honest, i don't think this rule is 
				   needed. the clearfix hack will resolve
				   renering issues associated with a floated
				   menu anyways. */
}

/*******************************************************************************
 * DROP POSITIONS
 *
 * This handles where sub-menus drops relative to the parent element. The same
 * attributes should be set in all rule sets in this section so that cascading
 * rules don't create problems.
 */
ul.rMenu-hor ul
{
	top: auto;		/* a value of 100% creates a problem in IE 5.0 
				   and Opera 7.23 */
	right: auto;
	left: auto;		/* typically want a value of 0 here but set to
				   auto for same reasons detailed above */
	margin-top: -1px;	/* so the top border of the dropdown menu 
				   overlaps the bottom border of its parent
				   horizontal menu. */
}
ul.rMenu-ver ul
{
	left: 60%;
	right: auto;
	top: auto;
	margin-top: -0.5em;	/* i prefer top: 80% but this creates a problem
				   in iCab so negative top margin must be used.
				   salt to taste. */
}
ul.rMenu-vRight ul, ul.rMenu-hRight ul.rMenu-ver ul
{
	left: -60%;
	right: auto;
	top: auto;
	margin-top: -0.5em;	/* i prefer top: 80% but this creates a problem
				   in iCab so negative top margin must be used.
				   salt to taste. */
}
ul.rMenu-hRight ul
{
	left: auto;
	right: 0;		/* this doesn't work in Opera 7.23 but 7.5 and
				   beyond work fine. this means right-aligned
				   horizontal menus break in Opera 7.23 and
				   earlier. no workaround has been found. */
	top: auto;
	margin-top: -1px;	/* so the top border of the dropdown menu 
				   overlaps the bottom border of its parent
				   horizontal menu. */
}

/*******************************************************************************
 * PRESENTATION : General
 *
 * This is where the visual presentation of the menu is handled. If you try to
 * alter the borders width or location of placement pay close attention to the
 * notes provided with the existing CSS rules in this section. There are key
 * reasons behind borders and negative margins being placed where they are.
 */
ul.rMenu li a
{
	border: solid 1px #99f	/* border around all anchor tags */
}
ul.rMenu-hor li
{
	margin-bottom: 0;	/* remove any negative bottom margin if the
				   horizontal menu is child of a vertical 
				   menu */
	margin-left: -1px;	/* negative borders on LIs to make borders on
				   child A elements overlap. they go here and
				   not on the A element for compatibility
				   reasons (IE6 and earlier) */
}
ul.rMenu-h
{
	padding-left: 1px ;	/* compensate for the 1px left jog created by
				   the above negative margin. */
}
ul.rMenu-ver li
{
	margin-left: 0;
	margin-top: -1px;	/* same thing above except for vertical
				   menus */
}
ul.rMenu-ver
{
	border-top: solid 1px #fff;	/* ditto */
}
ul.rMenu li a
{
	padding: 2px 5px 3px;	/* 2px top, 3px bottom always seems to
				   provide the most visually balanced 
				   padding */
}
ul.rMenu li a:link, ul.rMenu li a:hover, ul.rMenu li a:visited, ul.rMenu li a:active
{
	text-decoration: none;
}
ul.rMenu li.sfhover a:active,
ul.rMenu li:hover a:active
{
	color: #fff;
	background-color: #c00;
}
ul.rMenu li
{
	background-color: #ddf;	/* default background color of menu items */
}
ul.rMenu li:hover,
ul.rMenu li.sfhover
{
	background-color: #eda;	/* background color for parent menu items of
				   the current sub-menu. includes the sfhover
				   class which is used in the suckerfish hack
				   detailed later in this stylesheet. */
}
ul.rMenu li a:hover
{
	background-color: #ffc;
}

/*******************************************************************************
 * PRESENTATION : Expand
 *
 * the bits below implement a graphic to appear on those anchor elements which 
 * have the rMenu-expand class assigned. this is something you have to do
 * manually on any LI element containing a UL element that is to be a dropdown 
 * menu. there is no mechanism to do this automatically.
 *
 * the seemingly redundant CSS is done for reasons similar to the suckerfish
 * css. it's to deal with all sorts of nested menu issues. it'll work as far
 * as three levels deep, after that all bets off.
 */
ul.rMenu li.rMenu-expand a,
ul.rMenu li.rMenu-expand li.rMenu-expand a,
ul.rMenu li.rMenu-expand li.rMenu-expand li.rMenu-expand a
{
	padding-right: 25px;
	background-image: url("expand-right.gif");
	background-repeat: no-repeat;
	background-position: 100% 50%;
}
ul.rMenu-vRight li.rMenu-expand a,
ul.rMenu-vRight li.rMenu-expand li.rMenu-expand a,
ul.rMenu-vRight li.rMenu-expand li.rMenu-expand li.rMenu-expand a,
ul.rMenu-hRight li.rMenu-expand a,
ul.rMenu-hRight li.rMenu-expand li.rMenu-expand a,
ul.rMenu-hRight li.rMenu-expand li.rMenu-expand li.rMenu-expand a
{
	padding-right: 5px;
	padding-left: 20px;
	background-image: url("expand-left.gif");
	background-repeat: no-repeat;
	background-position: -5px 50%;
}
ul.rMenu-hor li.rMenu-expand a
{
	padding-left: 5px;	/* reset padding */
	padding-right: 15px;
	background-image: url("expand-down.gif");
	background-position: 100% 50%;
}
ul.rMenu li.rMenu-expand li a,
ul.rMenu li.rMenu-expand li.rMenu-expand li a,
ul.rMenu li.rMenu-expand li.rMenu-expand li.rMenu-expand li a
{
	background-image: none;
	padding-right: 5px;	/* reset padding */
	padding-left: 5px;	/* reset padding */
}

/*******************************************************************************
 * HACKS : General
 *
 * These are rules specifically targeted to resolve bugs/quirks that some
 * browser exhibit.
 */
* html ul.rMenu
{
	display: inline-block;	/* this is for IE/Mac. it forces IE/Mac to 
				   expand the element's dimensions to contain 
				   its floating child elements without a 
				   clearing element. */
	/* \*/ display: block;	/* override above rule for every other 
				   browser using IE/Mac backslash hack */
	position: relative;	/* IE 5.0/Mac needs this or it may clip the
				   dropdown menus */
	/* \*/ position: static;/* reset position attribute for IE/Win as it
				   causes z-index problems */
}
* html ul.rMenu ul
{
	float: left;		/* IE/Mac 5.0 needs this and IE/Win 6 and earlier
				   don't show any problems with applying this 
				   rule. */
}
ul.rMenu ul
{
	background-color: #fff;	/* IE/Win (includeing 7) needs this on an object 
				   that hasLayout so that it doesn't "look through"
				   the menu and let any object (text) below the 
				   menu to gain focus, causing the menu to 
				   disappear. application of this rule does not
				   cause any rendering problems with other browsers
				   as the background color his covered by the
				   menu itself. */
}
* html ul.rMenu-ver li,
* html ul.rMenu-hor li ul.rMenu-ver li
{
				/* the second selector in this rule is there 
				   because of problems IE/Mac has with 
				   inheritance and what rules should take
				   precedence. and to serve as a reminder on
				   how to work around the issue if it's 
				   encountered again down the road. */
	width: 100%;
	float: left;
	clear: left;		/* IE6 (and earlier?) stick space below any LI
				   in :hover state with a sub-menu. floating
				   the LIs seems to work around this issue. But
				   note that this also triggers hasLayout 
				   because we need a width of 100% on floats.
				   But hasLayout on LIs breaks the menu in IE7.
				   So we really need to be careful not to let
				   floats get into anything other than IE6
				   and earlier. IE Mac seems to need this
				   too for some other reason. */
}
ul.rMenu-ver li a
{
	min-width: 0;		/* trigger hasLayout for IE7 on anchor 
				   elements. without hasLayout on anchors
				   they would not expand the full width 
				   of the menu. this rule may not trigger
				   hasLayour in later versions of IE and
				   if you find this system broken in new
				   versions of IE, this is probably the
				   source. */
}
* html ul.rMenu-ver li a
{
	height: auto;		/* triggers hasLayout for IE/Mac */
	/* \*/ height: 100%;	/* trigger hasLayout for IE6 and earlier. does
				   not work for IE7 */
}
* html ul.rMenu-h
{	/* hide from IE Mac \*/
	padding-left: 2px;	/* IE6 and earlier double the negative margins
				   on the LI elements of horizontal menus. this
				   is because the LIs float but the parent
				   isn't floating. this can be fixed by floating
				   rMenu-hor but I'd rather not float it so I just
				   double up the padding used to compensate. */
}
* html ul.rMenu-hor li
{
	width: 6em;		/* IE Mac doesn't do auto widths so specify a width 
				   for the sake of IE/Mac. Salt to taste. */
	/* \*/ width: auto;	/* now undo previous rule for non Macs by using 
				   the IE Mac backslash comment hack */
}

/*******************************************************************************
 * HACKS : Suckerfish
 *
 * IE6 and earlier do not support the :hover pseudoclass and so javascript is 
 * used to add the "sfhover" class of any LI element that the mouse is currently 
 * over. This method is called suckerfish and you can read up on it at:
 * http://www.htmldog.com/articles/suckerfish/dropdowns/
 *
 * NOTE: this allows for support of dropdown menus up to 3 levels deep. if you 
 *	 want to support greather menu depth you need to alter these selectors. 
 *	 read the above mentioned website for more info on how to do that.
 */
* html ul.rMenu li.sfhover
{
	z-index: 999;
}
* html ul.rMenu li.sfhover ul ul, 
* html ul.rMenu li.sfhover ul ul ul
{ 
	display: none;		/* IE/Suckerfish alternative for browsers that
				   don't support :hover state on LI elements */
}
* html ul.rMenu li.sfhover ul, 
* html ul.rMenu li li.sfhover ul, 
* html ul.rMenu li li li.sfhover ul
{
	display: block;		/* ^ ditto ^ */
}

/*******************************************************************************
 * HACKS : Clearfix
 *
 * Clearfix provides a means to for an element to contain all it's floated 
 * children even if it's not normally tall enough to do so. For more information
 * on clearfix please see:
 * http://www.positioniseverything.net/easyclearing.html
 */
.clearfix:after
{
    content: "."; 
    display: block; 
    height: 0; 
    clear: both; 
    visibility: hidden;
}
.clearfix
{
	min-width: 0;		/* trigger hasLayout for IE7 */
	display: inline-block;
	/* \*/	display: block;	/* Hide from IE Mac */
}
* html .clearfix
{
	/* \*/  height: 1%;	/* Hide from IE Mac */ 
}

/******************************************************************************/

Ruthsarian Menus - A CSS-based dropdown menu system

sai-venkat/JRuby Jetlang Example ( Ruby)

require "java"
require "jetlang-0.2.0.jar"

include_class "org.jetlang.fibers.ThreadFiber"
include_class "org.jetlang.channels.MemoryChannel"


class Arnie
  def initialize(channel, consumer)
    @channel = channel
    @consumer = consumer
  end
  def start
    on_receive = Proc.new do |message|
      case message
        when "The End"
          puts "I will be back..."
          @consumer.dispose
          @consumer.join
        when "Terminate"
          puts "Hastala vista baby!!!"
        else
          puts "You are terminated******"
      end
    end
    @channel.subscribe(@consumer, on_receive)
    @consumer.start
  end
  def ^(message)
    @channel.publish(message)
  end
end

terminator = Arnie.new(MemoryChannel.new, ThreadFiber.new)
terminator.start
terminator ^ "Terminate"
terminator ^ "Buy me icecream"
terminator ^ "The End"
terminator ^ "Terminate" # Will not execute as terminator is already dead...

Raynes/Swing example in Clojure ( Lisp)

(ns rayne.main
  (:gen-class)
  (:import (javax.swing JFrame JTextField JButton JPanel BoxLayout BorderFactory)
           (java.awt.event ActionListener)
           (java.awt GridLayout BorderLayout Dimension)))

(def numbers (ref []))
(def times-clicked (ref 0))

(defn calc
  "Gets the numbers from the vector and calculates them"
  [[n1 n2] op]
    (cond
      (= op "+") (+ n1 n2)
      (= op "*") (* n1 n2)
      (= op "-") (- n1 n2)
      (= op "/") (try (double (/ n1 n2))
                 (catch ArithmeticException _ "Cannot divide by zero."))))

(defn proof-number
  "Returns n if n is a number. Returns 0 otherwise"
  [n]
  (if (number? n) n 0))

(defn add-op-button
  "Creates a new button and adds the works too it."
  [op text button]
  (.addActionListener button
      (proxy [ActionListener] []
        (actionPerformed [e]
        (dosync
          (ref-set numbers (conj @numbers (proof-number (read-string (.getText text)))))
          (ref-set times-clicked (inc @times-clicked))
          (.grabFocus text)
          (if (= @times-clicked 2)
            (do
              (let [result (.toString (calc @numbers op))]
                (.setText text result)
                (ref-set numbers [(read-string result)])
                (ref-set times-clicked 1)))
            (do
              (.setText text ""))))))))

(defn clear-button
  "Special case clear button"
  [button text]
  (.addActionListener button
    (proxy [ActionListener] []
      (actionPerformed [e]
        (dosync
          (ref-set times-clicked 0)
          (ref-set numbers [])
          (.setText text ""))))))

(defn -main
  "Main function, sets up the frame and glues everything together"
  []
  (let [frame (JFrame. "Calculator")
        add-button (JButton. "+")
        sub-button (JButton. "-")
        mul-button (JButton. "*")
        div-button (JButton. "/")
        clr-button (JButton. "Clear!")
        text-field (JTextField.)
        outter-pane (JPanel. (BorderLayout. 0 1))
        pane (JPanel. (GridLayout. 1 0))]
    (doto pane
      (.add add-button (add-op-button "+" text-field add-button))
      (.add sub-button (add-op-button "-" text-field sub-button))
      (.add mul-button (add-op-button "*" text-field mul-button))
      (.add div-button (add-op-button "/" text-field div-button))
      (.add clr-button (clear-button clr-button text-field)))
    (doto outter-pane
      (.add text-field BorderLayout/NORTH)
      (.add pane BorderLayout/EAST))
    (doto frame
      (.add outter-pane)
      (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
      (.setResizable false)
      (.setSize 341 100)
      (.setVisible true))))

This snippet creates a fully functional calculator with a simple GUI using the Swing GUI toolkit.

darkparadox/manage.php example ( PHP)

<html>
<?php
function setNav($cur)
{
	$code = '<div id="menu"><ul>';
	
	if($cur != "index") {$code = $code.'<li><a href="index.php">Index</a></li>';}
	else {$code = $code.'<li class="current_page_item"><a href="index.php">Index</a></li>';}
	
	if($cur != "games") {$code = $code.'<li><a href="games.php">Games</a></li>';}
	else {$code = $code.'<li class="current_page_item"><a href="games.php">Games</a></li>';}
	
	if($cur != "tutorials") {$code = $code.'<li><a href="tutorials.php">Tutorials</a></li>';}
	else {$code = $code.'<li class="current_page_item"><a href="tutorials.php">Tutorials</a></li>';}
	
	$code = $code.'<li><a href="forum/">Forum</a></li>';
	$code = $code.'</ul></div>';
	echo $code;
}

function setSidebar()
{
	echo '<div id="sidebar">
			<ul>
				<!-- Object start -->
				<li>
					<h2>Recent Updates</h2>
					<ul>
						<li></li>
						<li>6 new tutorials added to Games</li>
						<li>1 new utility added to Games</li>
						<li>Recent Updates updated to show something interesting finally</li>
						<li>Forum all pretty and mostly complete</li>
					</ul>
				</li>
				<!-- Object end -->
				
				<!-- Object start -->
				<li>
					<h2>Website info</h2>
					<ul>
						<li></li>
						<li>Founder/Admin: DarkParadox</li>
						<li>Created on: December 7, 2010</li>
					</ul>
				</li>
				<!-- Object end -->
				
				<!-- Object start -->
				<li>
				   <!-- Object start -->
					<h2>Links</h2>
					<ul>
						<li></li>
						<li><a href="http://www.game-editor.com">Game-Editor Website</a></li>
						<li><a href="http://game-editor.com/forum/viewtopic.php?f=1&amp;t=6834">Game-Editor Keyword Reference <br /> [Game-Editor Forum post]</a></li>
						<li><a href="http://game-editor.com/forum/viewtopic.php?f=4&amp;t=9093">Tutorials/Code-libs <br /> [Game-Editor Forum post]</a></li>
					</ul>
				</li>
				<!-- Object end -->
				
				<!-- Object start -->
				<li>
					<h2>Contact info</h2>
					<ul>
						<li></li>
						<li>
							Email me at: 
							<SCRIPT LANGUAGE="JavaScript">
								user = "admin";
								site = "paraplaygames.com";
	
								document.write("<a href=\\"mailto:" + user + "@" + site + "\\">");
								document.write(user + "@" + site + "</a>");
							</SCRIPT>
						</li>
					</ul>
				</li>
				<!-- Object end -->
			</ul>
		</div>';
}

function setFooter() {
	echo '<div id="footer" text-align="center">
	Copyright © 2001-'.date("Y").' ─ Paraplay Games All rights reserved.
	</div>';
}

?>
</html>

mcculley/JavaScript Swing Application ( JavaScript)

javax.swing.SwingUtilities.invokeLater(function() {
  var frame = new Packages.javax.swing.JFrame();
  frame.defaultCloseOperation = javax.swing.JFrame.EXIT_ON_CLOSE;

  var menuBar = new Packages.javax.swing.JMenuBar();
  frame.setJMenuBar(menuBar);

  var fileMenu = new Packages.javax.swing.JMenu("File");
  menuBar.add(fileMenu);

  importClass(Packages.javax.swing.JMenuItem);

  var openItem = new JMenuItem("Open...");
  openItem.addActionListener(function() {
      print("put your file open code here!\n");
  });
  fileMenu.add(openItem);

  fileMenu.add(new Packages.javax.swing.JSeparator());

  var quitItem = new JMenuItem("Quit");
  quitItem.addActionListener(function() {
      java.lang.System.exit(0);
  });
  fileMenu.add(quitItem);

  frame.setSize(640, 480);
  frame.visible = true;
});

// Park the main thread.  Otherwise the application would immediately exit.
java.util.concurrent.locks.LockSupport.park();

A simple example of creating a Swing application using the JavaScript support provided by the Scripting API.

/Audio (Audio.java) ( Java)

package org.example.audio;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.KeyEvent;

public class Audio extends Activity {
    private MediaPlayer up, down, left, right, enter;
    private MediaPlayer a, s, d, f;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // Native rate is 44.1kHz 16 bit stereo, but
        // to save space we just use MPEG-3 22kHz mono
        up = MediaPlayer.create(this, R.raw.up);
        down = MediaPlayer.create(this, R.raw.down);
        left = MediaPlayer.create(this, R.raw.left);
        right = MediaPlayer.create(this, R.raw.right);
        enter = MediaPlayer.create(this, R.raw.enter);
        a = MediaPlayer.create(this, R.raw.a);
        s = MediaPlayer.create(this, R.raw.s);
        d = MediaPlayer.create(this, R.raw.d);
        f = MediaPlayer.create(this, R.raw.f);
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        MediaPlayer mp;
        switch(keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP: mp = up; break;
        case KeyEvent.KEYCODE_DPAD_DOWN: mp = down; break;
        case KeyEvent.KEYCODE_DPAD_LEFT: mp = left; break;
        case KeyEvent.KEYCODE_DPAD_RIGHT: mp = right; break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            mp = enter;
            break;
        case KeyEvent.KEYCODE_A: mp = a; break;
        case KeyEvent.KEYCODE_S: mp = s; break;
        case KeyEvent.KEYCODE_D: mp = d; break;
        case KeyEvent.KEYCODE_F: mp = f; break;
        default:
            return super.onKeyDown(keyCode, event);
        }
        mp.seekTo(0);
        mp.start();
        return true;
    }
}

from "Hello Android 2nd Edition" (ISBN: 1-934356-49-2)

erik.price/Java Screenshot Grabber ( Java)

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class ScreenGrabber {

    private BufferedImage img; //to store the result of the screen grab before writing to a file
    private File outFile; //output file
    private Robot robby = null; //Robby the Robot! (to provide screen grab methods)
    private String out; //name of file
    private Dimension screenSize; //size of screen
    private pictureType pic; //picture type
    private String picString; //String value of picture type (required for ImageIO.write())

    public enum pictureType {PNG, GIF, JPEG, BMP}; //various available picture types

    public ScreenGrabber() { //default constructor
        out = "output.png";
        screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //get screen size
        pic = pictureType.PNG;
        init(); //just to keep everything nice and neat
    }

    public ScreenGrabber(String out) { //Constructor for customized output file
        this.out = out;
        screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        init();
    }

    public ScreenGrabber(String out, pictureType pic, Dimension dim) { //constructor for customized dimensions/ filetype
        this.out = out;
        this.pic = pic;
        this.screenSize = dim;
        init();
    }

    public BufferedImage capture() //grab the image
    {
        this.img = robby.createScreenCapture(new Rectangle(screenSize.width, screenSize.height));
        return this.img;
    }

    public void write() throws IOException //remember to handle this!
    {
        outFile = new File(this.out); //only declared here so a file isn't created when the screengrab isn't saved
        ImageIO.write(img, picString, outFile);
    }

    private void init() {
        try {
            robby = new Robot();
            switch(pic)
            {
                case PNG:
                    picString = "png";
                    break;
                case GIF:
                    picString = "gif";
                    break;
                case JPEG:
                    picString = "jpeg";
                    break;
                case BMP:
                    picString = "bmp";
                    break;                
            }
        } catch (Exception e) {
            System.exit(-1); //change this if you want to actually handle errors instead of give up
        }
    }
}


/*example usage*/
public class Main {
    public static void main(String[] args) throws IOException //I did throws IOException to keep it simple since I knew this would work. Don't be lazy, and handle this correctly, unlike me{
        ScreenGrabber grab = new ScreenGrabber("output.bmp", pictureType.BMP,
                 Toolkit.getDefaultToolkit().getScreenSize());
        grab.capture(); //grab that screen! (and discard the BufferedImage it returns)
        grab.write(); //write it!      
    }
}

Uses java.awt.Robot to grab a screenshot.

/Sudoku (Keypad.java) ( Java)

package org.example.sudoku;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

public class Keypad extends Dialog {
    protected static final String TAG = "Sudoku";
    
    private final View keys[] = new View[9];
    private View keypad;
    
    private final int useds[];
    private final PuzzleView puzzleView;
    
    public Keypad(Context context, int useds[], PuzzleView puzzleView) {
        super(context);
        this.useds = useds;
        this.puzzleView = puzzleView;
    }
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setTitle(R.string.keypad_title);
        setContentView(R.layout.keypad);
        findViews();
        for(int element : useds) {
            if(element != 0)
                keys[element - 1].setVisibility(View.INVISIBLE);
        }
        setListeners();
    }
    
    private void findViews() {
        keypad = findViewById(R.id.keypad);
        keys[0] = findViewById(R.id.keypad_1);
        keys[1] = findViewById(R.id.keypad_2);
        keys[2] = findViewById(R.id.keypad_3);
        keys[3] = findViewById(R.id.keypad_4);
        keys[4] = findViewById(R.id.keypad_5);
        keys[5] = findViewById(R.id.keypad_6);
        keys[6] = findViewById(R.id.keypad_7);
        keys[7] = findViewById(R.id.keypad_8);
        keys[8] = findViewById(R.id.keypad_9);
    }
    
    private void setListeners() {
        for(int i = 0; i < keys.length; i++) {
            final int t = i + 1;
            keys[i].setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    returnResult(t);
                }});
        }
        keypad.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                returnResult(0);
            }});
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        int tile = 0;
        switch(keyCode) {
        case KeyEvent.KEYCODE_0:
        case KeyEvent.KEYCODE_SPACE: tile = 0; break;
        case KeyEvent.KEYCODE_1:     tile = 1; break;
        case KeyEvent.KEYCODE_2:     tile = 2; break;
        case KeyEvent.KEYCODE_3:     tile = 3; break;
        case KeyEvent.KEYCODE_4:     tile = 4; break;
        case KeyEvent.KEYCODE_5:     tile = 5; break;
        case KeyEvent.KEYCODE_6:     tile = 6; break;
        case KeyEvent.KEYCODE_7:     tile = 7; break;
        case KeyEvent.KEYCODE_8:     tile = 8; break;
        case KeyEvent.KEYCODE_9:     tile = 9; break;
        default:
            return super.onKeyDown(keyCode, event);
        }
        if(isValid(tile)) {
            returnResult(tile);
        }
        return true;
    }
    
    private boolean isValid(int tile) {
        for(int t : useds) {
            if(tile == t) return false;
        }
        return true;
    }
    
    /** Return the chosen tile to the caller */
    private void returnResult(int tile) {
        puzzleView.setSelectedTile(tile);
        dismiss();
    }
}

from "Hello Android 2nd Edition" (ISBN: 1-934356-49-2)