A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Answer :Run time error / why?
tian Lau
Greenhorn
Joined: Jul 10, 2000
Posts: 20
posted
Jul 14, 2000 23:04:00
0
import
java.applet.Applet
;
import java.awt.*;
public class Sample extends
Applet
{
private
String
text = "Hello World";
public void init() {
add(new Label(text));
}
public Sample (String string) {
text = string;
}
}
It is accessed form the following HTML page:
<html>
<title>Sample Applet</title>
<body>
<applet code="Sample.class" width=200 height=200></applet>
</body>
</html>
kevin jia
Ranch Hand
Joined: Jul 13, 2000
Posts: 38
posted
Jul 14, 2000 23:21:00
0
Applet can't hava constructor with arguments. It can have constructor no arguments.
kevin jia
Ranch Hand
Joined: Jul 13, 2000
Posts: 38
posted
Jul 14, 2000 23:56:00
0
Try the code below, maybe you can find answer.
import
java.applet.Applet
;
import java.awt.*;
public class Sample extends Applet {
String text;
public void init() {
add(new Label(text));
}
public Sample() {
text = "Hello cruel world!";
}
<html>
<body>
<applet code="Sample.class" width=200 height=200>
</applet>
</body>
</html>
I agree. Here's the link:
http://aspose.com/file-tools
subject: Answer :Run time error / why?
Similar Threads
Mock Exam
applet
Applet
Doubts in Applet
Mock Exam
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter