Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problem with appletviewer
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



Report this thread to moderator Post Follow-up to this message
Old Post
Chris \( Val \)
04-25-05 01:59 PM


Re: Problem with appletviewer
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 ;)



--
Peter MacMillan
e-mail/msn: peter@writeopen.com

Report this thread to moderator Post Follow-up to this message
Old Post
Peter MacMillan
04-25-05 01:59 PM


Re: Problem with appletviewer
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Chris \( Val \)
04-25-05 01:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:23 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.