> public class printtest extends java.applet.Applet
> public static void main (String args)
> {
That should be:
public static void main(String[] args) {
> }
But it still wont do anything.
Applets run in web pages. You'll need something like this in an HTML
file (in the same directory as your class file):
<applet class="printtest.class" width="100" height="100"></applet>
Then either view the web page in your browser (if it has a sufficiently
recent version of Java enabled) or use appletviewer.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Jacky Luk - 20 Sep 2006 20:05 GMT
How do you make the paint method work?
Thanks
Jack
"Thomas Hawtin" <usenet@tackline.plus.com>
???????:45118f8b$0$2663$ed2619ec@ptn-nntp-reader02.plus.net...
>> public class printtest extends java.applet.Applet
>
[quoted text clipped - 17 lines]
>
> Tom Hawtin
Thomas Hawtin - 20 Sep 2006 20:23 GMT
> How do you make the paint method work?
Works for me... My entire (Java 1.5) code:
import java.awt.Graphics;
public class PrintTest extends java.applet.Applet {
@Override
public void paint(Graphics g) {
g.drawString("Hello from java!", 60, 30);
}
}
<applet code="PrintTest.class" width="100" height="100"></applet>
(Note that's code= not class= as I said earlier.)
Are you sure it's running? No exception messages in the terminal/console
for appletviewer or Java console of your web browser?
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Jacky Luk - 20 Sep 2006 23:35 GMT
Severity Description Resource In Folder Location Creation Time Id
2 The public type PrintTest must be defined in its own file printtest.java
test1 line 3...
1 The serializable class PrintTest does not declare a static final
serialVersionUID field of type long printtest.java test1 line 3...
"Thomas Hawtin" <usenet@tackline.plus.com>
???????:45119539$0$559$ed2619ec@ptn-nntp-reader03.plus.net...
>> How do you make the paint method work?
>
[quoted text clipped - 17 lines]
>
> Tom Hawtin
Andrew Thompson - 20 Sep 2006 23:49 GMT
> > public class printtest extends java.applet.Applet
....
> public static void main(String[] args) {
...
> But it still wont do anything.
Sure it will*. Adding a main allows you to run your applet as
either an applet or an application. Most of my applets have mains
(even if I never intend to use them as applications) simply
because it can be so much quicker developing something
you can simply launch from the command line.
* So long as the main creates a frame, instantiates the
applet class, calls init() and adds it to the frame.
Andrew T.