Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2005

Tip: Looking for answers? Try searching our database.

Problem with appletviewer

Thread view: 
Chris \( Val \) - 25 Apr 2005 03:06 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.