Reputation: 2778
import java.awt.*;
import java.applet.*;
public class IdrawApplet extends Applet {
Button myButton;
Panel pPanel;
public void init() {
myButton=new Button("Clear");
pPanel = new Panel();
pPanel.setLayout(new BorderLayout());
pPanel.add(myButton,BorderLayout.NORTH);
}
}
Why dont't I see anything when I run it? Plus I get a strange Warning.
"The serializable class IdrawApplet does not declare a static final serialVersionUID field of type long."
Thanks in advance
Upvotes: 0
Views: 501
Reputation: 324118
Why don't I see anything when I run it?
You don't add the panel to the applet.
Since you are just learning applets, why don't you start by creating a Swing applet instead of an AWT applet. Read the section from the Swing tutorial on How to Make Applets for a working example to get you started.
Upvotes: 3
Reputation: 137322
You added the button to the panel, but you didn't add the panel to the applet:
add(pPanel);
Upvotes: 2
Reputation: 5023
You have to add the panel to the applet itself using its add() method.
You can (almost safely) ignore the warning or just add this to the class's variables:
private static final long serialVersionUID = 1L;
Upvotes: 2