To get it to compile, change
ring.paint();
..to..
ring.repaint();
Notes
- Don't code using AWT in this millennium. Use Swing (which offers a
JApplet
).
- Don't start an applet from the
main(String[])
. An applet is started by the JRE when it is embedded in a web page (or launched using JWS). A GUI can be designed in a panel, that is then put in a free-floating application or applet. That is known as a hybrid. But both frame and applet separately add the GUI, which is (most often) a different class to either.
- The main as it exists is useless. Unless the applet is added to a container and made visible, the code will run successfully but end in a few moments without displaying anything.
Update 1
..tried that, but it still doesn't draw my string in the applet window.
Try this.
Source
// <applet code='PaintMe' width=300 height=50></applet>
import java.applet.Applet;
import java.awt.*;
public class PaintMe extends Applet {
public void paint(Graphics g) {
g.setColor(Color.red);
g.drawString("HELLOOO", 15, 25);
}
}
Prompt
> javac PaintMe.java
> appletviewer PaintMe.java
Screenshot

Update 2
..I need to have it started from Starter.java class.
I think that is a silly requirement, and it seems like JWS (as mentioned & linked in comments) launching a JFrame
is the best way to view this GUI. OTOH, here is a (very) naive implementation of the Starter
class that will show that applet on-screen.
It mixes AWT and Swing (bad), it does not attempt to implement any sort of applet context, and does not call the applet init
/start
/stop
/destroy
methods, but is enough to get the applet on-screen from another class.

import java.awt.Dimension;
import javax.swing.JOptionPane;
public class Starter {
public static void main(String[] args) {
PaintMe ring = new PaintMe();
ring.setPreferredSize(new Dimension(250,30));
JOptionPane.showMessageDialog(null, ring);
}
}