htmlApplet
Java applet class
[Previous] [Main] [Next]


Description
htmlApplet encapsulates the <APPLET></APPLET> tags, and is used to specify a Java applet that runs in a web page. Applets can only be display by Java-enabled browsers. Java applets and written in the Java programming language and compiled into a file or files using a Java compiler. The Java programming language is beyond the scope of this document. For more information on Java, you may wish to visit the following web site:  
 
http://java.sun.com/docs/books/tutorial/  
 
Once a Java applet is compiled and ready for use, you can use the Code() method to specify the name of the applet. The Codebase() method is used to specify the name of the subdirectory or URL containing the applet file.  
 
Many applets require optional parameters for which specific methods cannot be created. To use such options, use the Param() method to specify applet-specific parameter names and values. You can also add htmlParam objects to an htmlApplet object using the Add() method or the << insertion operator, which have been overloaded to accept only htmlParam objects.  
 
Some browsers will not display applets unless their dimensions are specified. To ensure that the applet will display properly on the widest variety of browsers, use the Height() and Width() methods to specify the dimensions in pixels, or as a percentage of the display area.  
 
Declaration
#include <dcmicro/htmlpp/applet.h>  
 
Hierarchy
htmlapplet.gif  

See Also
htmlParam, htmlScript, htmlPlugIn  
 
Related Constants/Definitions
typedef enum {  
   align_default = 0,  
   align_left,  
   align_center,  
   align_right,  
   align_justify  
} Alignment ;  
 
typedef enum {  
   valign_default = 0,  
   valign_top = align_justify + 1,  
   valign_middle,  
   valign_bottom,  
   valign_baseline  
} VerticalAlignment ;  
 
Constructors
htmlApplet()  
Constructs an empty Java applet object.  
 
htmlApplet(const String& codebase_url,  
   const String& code,  
   const String& height,  
   const String& width )  
Constructs a Java applet object, specifying code as the name of the applet to load from the directory or URL codebase_url, using dimensions height and width (which may be expressed as percentages or pixels).  
 
htmlApplet( const htmlApplet& rhs )  
Copy constructor.  
 
Destructor
virtual ~htmlApplet()  
Destroys the object.  
 
Member Methods
<<   htmlApplet& operator<< ( const htmlParam& param )  
Adds the parameter object param to the applet and returns a reference to the object.  
 
Add   virtual htmlObject FAR * Add( const htmlParam& param )  
Adds the parameter object param to the applet, returning a pointer to the new object.  
 
Code htmlApplet& Code( const String& filename )  
Sets the filename of the Java applet to load to filename, and returns a reference to the object. This value is required. All Java class files contain a name suffix of ".class".  
 
Code String Code() const  
Returns the filename of the Java applet to load, or an empty string if not set.  
 
CodebasehtmlApplet& Codebase( const String& file_directory_url )  
Sets the directory containing the applet class file and any resources to file_directory_url, a URL for an absolute or relative pathname. A reference to the object is returned.  
 
CodebaseString Codebase() const  
Returns the directory pathname containing the applet class file and any resources as a string, or an empty string if not set.  
 
ArchivehtmlApplet& Archive( const String& archive_file )  
Sets the filename to be downloaded and searched for the class file specified in the Code() method to archive_file, and returns a reference to the object. The archive file must contain a suffix of ".zip", but must not be compressed.  
 
ArchiveString Archive() const  
Returns the archive name as a string, or an empty string if not set.  
 
AltTexthtmlApplet& AltText( const String& text )  
Sets the text to be displayed by browsers that are unable to display Java applets to text, and returns a reference to the object.  
 
AltTextString Archive() const  
Returns the alternate text setting for the object, or an empty string if not set.  
 
Align   htmlApplet& Align( Alignment align )  
Sets the horizontal alignment for the applet to align, and returns a reference to the object. Align() and VAlign() are mutually exclusive attributes.  
 
  • align_left The applet is aligned with the left margin. Content flows around the right edge of the applet. The htmlBreak::ClearMargin() method can be used to force content to fall below the applet.
  • align_right The applet is aligned with the right margin. Content flows around the left edge of the applet. The htmlBreak::ClearMargin() method can be used to force content to fall below the applet.
 
VAlignhtmlApplet& VAlign( VerticalAlignment v_align )  
Sets the vertical alignment for the applet to align, and returns a reference to the object. Align() and VAlign() are mutually exclusive attributes.  
 
  • valign_top The top of the applet is vertically aligned with the tallest element in the current line.
  • valign_middle The applet is vertically aligned in the middle of the current line.
  • valign_bottom The bottom of the applet is aligned vertical with the bottom of the elements in the current line.
  • valign_baseline Same as align_bottom
  • valign_texttop The applet is aligned with the top of the tallest text in the current line.
 
Align   int Align() const  
Returns the alignment (horizontal or vertical) for the applet as an integer, or align_default if not set.  
 
HeighthtmlApplet& Height( const String& pixels_or_percent )  
Sets the applet height, and returns a reference to the object. An integer value for pixels_or_percent sets the height in pixels. A string containing a "%" character scales the applet height as a percentage of the parent window, frame, or content block. Both a height and width should be specified in order for the applet to display properly on the widest variety of browsers.  
 
HeightString Height() const  
Returns the applet height as a string (representing pixel size or a percentage of the display), or an empty string if not set.  
 
WidthhtmlApplet& Width( const String& pixels_or_percent )  
Sets the applet width, and returns a reference to the object. An integer value for pixels_or_percent sets the width in pixels. A string containing a "%" character scales the applet width as a percentage of the parent window, frame, or content block. Both a height and width should be specified in order for the applet to display properly on the widest variety of browsers.  
 
WidthString Width() const  
Returns the applet height as a string (representing pixel size or a percentage of the display), or an empty string if not set.  
 
HSpacehtmlApplet& HSpace( int pixels )  
Sets the horizontal space between the applet and it's surroundings, and returns a reference to the object. If pixels is a negative value, the attribute is cleared.  
 
HSpaceint HSpace() const  
Returns the horizontal space setting in pixels, or zero if not set.  
 
VSpacehtmlApplet& VSpace( int pixels )  
Sets the vertical space between the applet and it's surroundings, and returns a reference to the object. If pixels is a negative value, the attribute is cleared.  
 
VSpaceint VSpace() const  
Returns the vertical space setting in pixels, or zero if not set.  
 
EnableScripthtmlApplet& EnableScript( Boolean enable_javascript_access = TRUE )  
Specifies whether or not the applet can access JavaScript on a page, and returns a reference to the object. If an applet attempt to access JavaScript without enabling this option, the browser will generate an exception. This method corresponds to the MAYSCRIPT attribute.  
 
IsScriptEnabled Boolean IsScriptEnabled()  
Returns TRUE if the applet has permission to access JavaScript on a page, FALSE if not.  
 
NamehtmlApplet& Name( const String& name )  
Sets the JavaScript-accessible name of the applet to name, and returns a reference to the object.  
 
NameString Name() const  
Returns the JavaScript-accessible name of the applet as a string, or an empty string if not set.  
 
ParamhtmlApplet& Param( const String& name, const String& value )  
Adds name and value as a custom parameter for the applet, then returns a reference to the object. Internally, an htmlParam object is created and the name and value arguments are passed to it.  
 
Print   void Print( ostream& os ) const  
Outputs the object to os.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Example Use
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi    server ;  
   htmlPage   page( "html++ example application" ) ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
</BODY>  
</HTML>  
 
 



©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.