alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jetty example source code file (Applet.java)

This example Jetty source code file (Applet.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jetty tags/keywords

applet, applet, block, composite, composite, enumeration, hashtable, hashtable, io, ioexception, string, string, util

The Jetty Applet.java source code

// ========================================================================
// $Id: Applet.java,v 1.7 2004/07/19 13:12:58 hlavac Exp $
// Copyright 1996-2004 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at 
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================

package org.mortbay.html;

import java.io.IOException;
import java.io.Writer;
import java.util.Enumeration;
import java.util.Hashtable;

/* ---------------------------------------------------------------- */
/** An Applet Block.
 * <p> Lets you set the class name from the program, and optionally, the
 * size and the codebase.
 *
 * <p> This class uses any attributes set in Element.
 *
 * <p>

Usage

* <pre> * org.mortbay.Page page = new org.mortbay.html.Page(); * page.add(new org.mortbay.Applet("org.mortbay.Foo.App")); * </pre> * * @see org.mortbay.html.Block * @version $Id: Applet.java,v 1.7 2004/07/19 13:12:58 hlavac Exp $ * @author Matthew Watson */ public class Applet extends Block { /* ------------------------------------------------------------ */ public String codeBase = null; /* ------------------------------------------------------------ */ private boolean debug =false; private Hashtable params = null; private Composite paramHolder = new Composite(); /* ------------------------------------------------------------ */ /** Create an Applet Element. * @param className The name of the class to give for the applet */ public Applet(String className) { super("applet"); add(paramHolder); attribute("code",className); } /* ------------------------------------------------------------ */ /** Set the dimensions of the Applet. */ public Applet setDimensions(int height, int width) { width(width); height(height); return this; } /* ------------------------------------------------------------ */ /** Set whether debugging is on in the Applet. * <p> This controls whether the org.mortbay.util.Code debug messages * will be printed to the java console. * <p> Defaults to whether debug is turned on in the generating app */ public Applet setDebug(boolean debug){ this.debug = debug; return this; } /* ------------------------------------------------------------ */ /** * Set an alternate display for non-java browsers. * @param alt The alternate element to display * @deprecated use add */ public Applet setAlternate(Element alt) { add(alt); return this; } /* ------------------------------------------------------------ */ /** Set an alternate display for non-java browsers. * @param alt The alternate element to display * @deprecated use add */ public Applet setAlternate(String alt) { add(alt); return this; } /* ------------------------------------------------------------ */ /** Set the codebase */ public Applet codeBase(String cb) { codeBase = cb; return this; } /* ------------------------------------------------------------ */ public Applet setParam(String name, String value) { if (params == null) params = new Hashtable(10); params.put(name, value); return this; } /* ------------------------------------------------------------ */ /** Write out the HTML */ public void write(Writer out) throws IOException { if (codeBase != null) attribute("codebase",codeBase); if (debug) paramHolder.add("<param name=\"debug\" value=\"yes\">"); if (params != null) for (Enumeration enm = params.keys(); enm.hasMoreElements();) { String key = enm.nextElement().toString(); paramHolder.add("<param name=\"" + key + "\" value=\"" + params.get(key).toString() + "\">"); } super.write(out); } };

Other Jetty examples (source code examples)

Here is a short list of links related to this Jetty Applet.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.