import java.io.*; /** Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class NegativeLengthException extends Exception { /** Test NegativeLengthException */ public static void main(String[] args) { try { …
Category: Code . Programming Samples . প্রোগ্রাম উদাহরন
Code . Programming Samples . প্রোগ্রাম উদাহরন
Aug 29
TreeTest.java Builds a binary tree and prints the contents of the nodes. Uses the following classes:
Treetest.java /** A NodeOperator that prints each node. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ class PrintOperator implements NodeOperator { public void operateOn(Node node) { System.out.println(node.getNodeValue()); …
Aug 29
Illustrates the use of arrays
/** Report on a round of golf at St. Andy?s. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class Golf { public static void main(String[] args) { …
Aug 29
Factorial.java Computes an exact factorial, n!, using a BigInteger
import java.math.BigInteger; /** Computes an exact factorial, using a BigInteger. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class Factorial { public static void main(String[] args) { …
Aug 29
Exec.java Provides static methods for running external processes from applications.
import java.io.*; /** A class that eases the pain of running external processes * from applications. Lets you run a program three ways: * * exec: Execute the command, returning * immediately even if the command is still running. * This would be appropriate for printing a file. …
Aug 29
Controlling Image Loading
~~~~~~~~~~~~~~~~~~~ ImageBox.java A class that incorrectly tries to load an image and draw an outline around it. The problem is that the size of the image is requested before the image is completely loaded, thus, returning a width and height of -1. ~~~~~~~~~~~~~~~~~~~ import java.applet.Applet; import java.awt.*; /** A class that incorrectly tries to load …
Aug 29
HelloWWW2.java Illustrates the ability of an applet to read parameters contained in the HTML document
HelloWWW2.java Illustrates the ability of an applet to read parameters contained in the HTML document (PARAM element containing a NAME-VALUE pair). &&&&&&&&&&&&&&&&&&&&&&&&&&&&&& import java.applet.Applet; import java.awt.*; ************************* public class HelloWWW2 extends Applet { public void init() { setFont(new Font(“SansSerif”, Font.BOLD, 30)); Color background = Color.gray; Color foreground = Color.darkGray; String …
Aug 29
An example Travel Site
quick-search.html Front end to travel site <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Front end to travel servlet. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>Online Travel Quick Search</TITLE> <LINK REL=STYLESHEET HREF=”travel-styles.css” …
Aug 29
GetElementsByName an example: Checkbox
<html> <head> <script type=”text/javascript”> function getElements() { var x=document.getElementsByName(“myInput[]”); alert(x.length); alert(x[0].value); alert(x[1].value); alert(x[2].value); } </script> </head> <body> <input …
Aug 29
IfExample.jsp Page that uses the custom nested tags
IfExample.jsp Page that uses the custom nested tags <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of IfTag tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>If Tag Example</TITLE> <LINK REL=STYLESHEET HREF=”JSP-Styles.css” TYPE=”text/css”> </HEAD> …