AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with appletviewer

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Chris ( Val )
Guest





PostPosted: Mon Apr 25, 2005 2:06 am    Post subject: Problem with appletviewer Reply with quote



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


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.