Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageChris ( Val ) wrote: > 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: > > > 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 ;) -- Peter MacMillan e-mail/msn: peter@writeopen.com
Post Follow-up to this message"Peter MacMillan" <peter@writeopen.com> wrote in message news:PNudnYW8KvwPy_HfRVn-pA@rogers.com... | Chris ( Val ) wrote: | > 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: | > | > | > | | 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 ;) I'll just go and crawl back into my hole now :-) Thanks for waking me up <G>. Cheers, Chris Val
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.