Category: Java/J2EE/J2ME

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> …

Continue reading

Statics.java Demonstrates static and non-static methods.

*/ public class Statics {  public static void main(String[] args) {     staticMethod();     Statics s1 = new Statics();     s1.regularMethod();   }   public static void staticMethod() {     System.out.println(“This is a static method.”);   }   public void regularMethod() {     System.out.println(“This is a regular method.”);   } }

Batton’s java

import java.applet.Applet; import java.awt.*; /././././././ public class Buttons extends Applet {   private Button button1, button2, button3;     public void init() {     button1 = new Button(“Button One”);     button2 = new Button(“Button Two”);     button3 = new Button(“Button Three”);     add(button1);     add(button2);     add(button3);   } } /././././././././.

IfTag.java, IfConditionTag.java, IfThenTag.java, and IfElseTag.java, Custom tags that make use of tag nesting

IfTag.java, IfConditionTag.java, IfThenTag.java, and IfElseTag.java, Custom tags that make use of tag nesting IfTag.java package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; import javax.servlet.*; /** A tag that acts like an if/then/else.  *  <P>  *  Taken from Core Web Programming Java 2 Edition  *  from Prentice Hall and Sun Microsystems Press,  *  .  *  May …

Continue reading

FilterExample.jsp Page that uses the FilterTag custom tag

FilterExample.jsp Page that uses the FilterTag custom tag <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of FilterTag 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>HTML Logical Character Styles</TITLE> <LINK REL=STYLESHEET       HREF=”JSP-Styles.css”       TYPE=”text/css”> …

Continue reading

Demonstrates using a TexturePaint to fill an shape with a tiled image

^^^^^^^^^^^^^^^^^ TiledImages.java Demonstrates using a TexturePaint to fill an shape with a tiled image. Uses the following class and images:     * ImageUtilities.java Simplifies creating a BufferedImage from an image file. ~~~~~~~~~~~~~~~~~~ import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; /** An example of using TexturePaint to fill objects with tiled  *  images. Uses the …

Continue reading

Draws a filled ellipse

import javax.swing.*;   // For JPanel, etc. import java.awt.*;      // For Graphics, etc. import java.awt.geom.*; // For Ellipse2D, etc. /** An example of drawing/filling shapes with Java 2D in  *  Java 1.2 and later.  * ************************** public class ShapeExample extends JPanel {   private Ellipse2D.Double circle =     new Ellipse2D.Double(10, 10, 350, 350);   private Rectangle2D.Double …

Continue reading

JavaTextField.java

import java.applet.Applet; import java.awt.*; /** Lets the user enter the name of any  *  good programming language. Or does it?  *    ********************* public class JavaTextField extends Applet {   public void init() {     setFont(new Font(“Serif”, Font.BOLD, 14));     setLayout(new GridLayout(2, 1));     add(new Label(“Enter a Good Programming Language”,                   Label.CENTER));     LanguageField langField …

Continue reading

Applet that uses processXxx methods to print detailed reports on mouse events. Illustrates low-level alternative to handling events with listeners.

import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** Prints non-detailed reports of mouse events.  *  Uses the low-level processXxxEvent methods instead  *  of the usual event listeners.  *    ***************** public class MouseReporter extends Applet {   public void init() {     setBackground(Color.blue); // So you can see applet in page     enableEvents(AWTEvent.MOUSE_EVENT_MASK |                  AWTEvent.MOUSE_MOTION_EVENT_MASK); …

Continue reading

HeadingExample.jsp Page that uses the HeadingTag custom tag

HeadingExample.jsp Page that uses the HeadingTag custom tag <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Illustration of HeadingTag 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>Some Tag-Generated Headings</TITLE> </HEAD> <BODY> <%@ taglib uri=”cwp-taglib.tld” prefix=”cwp” %> …

Continue reading