Hi all,
I have the following code, which compiles fine, and I can
view this applet successfully in my web page when I embed
it in the <APPLET> tags - Even my output statements are
working correctly when viewed in the Java Console.
Having said that however, I cannot get this to work with
the 'appletviewer' - That is: I cannot get the viewer to
show up at all, so I cannot view this applet outside of
the browser for some reason. For example, if I type:
C:\>appletviewer DateTime
I/O exception while reading:
C:\DateTime (The system cannot find the file specified)
OR... C:\>appletviewer DateTime.
I/O exception while reading:
C:\DateTime. (The system cannot find the file specified)
OR... C:\> appletviewer DateTime.class
Nothing at all happens - No viewer, no errors.
The title of the command window flashes very quickly like the
viewer has started, but then nothing - I just get the command prompt.
Any ideas?
I am running Win XP SP2, and...
C:\>java -showversion
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
Here is the code:
import java.applet.*;
import java.text.*;
import java.util.*;
import java.awt.*;
public class DateTime extends Applet
{
public void paint( Graphics g )
{
System.out.println( "Start of paint() method" );
// Format the current date / time...
System.out.println( "Formatting the date/time" );
DateFormat df = DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT );
String str = df.format( new Date() );
System.out.println( "The date/time is: " + str );
// Draw the date / time...
System.out.println( "Drawing the date/time" );
FontMetrics fm = g.getFontMetrics();
g.drawString( str, (getSize().width - fm.stringWidth( str ) ) / 2,
( (getSize().height - fm.getHeight()) / 2) + fm.getAscent() );
System.out.println( "End of paint() method" );
}
}
Cheers,
Chris Val
Peter MacMillan - 25 Apr 2005 03:31 GMT
Chris ( Val ) wrote:
> Hi all,
>
[quoted text clipped - 7 lines]
> show up at all, so I cannot view this applet outside of
> the browser for some reason. For example, if I type:
Create a file named DateTime.html with the following content and save it
in the same directory:
<html>
<head></head>
<body>
<applet code="DateTime.class" width="200" height="200"></applet>
</body>
</html>
Then run:
appletviewer DateTime.html
and enjoy ;)

Signature
Peter MacMillan
e-mail/msn: peter@writeopen.com
Chris \( Val \) - 25 Apr 2005 03:40 GMT
| Chris ( Val ) wrote:
| > Hi all,
[quoted text clipped - 24 lines]
|
| and enjoy ;)
I'll just go and crawl back into my hole now :-)
Thanks for waking me up <G>.
Cheers,
Chris Val