This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError for JApplet

 
Frances F
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is a code:--
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class MyPanel extends JPanel{
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("My Panel",75,100);
}
}

public class MyApplet extends JApplet{
public void init(){
Container contentPane=getContentPane();
contentPane.add(new MyPanel());
}
}
The tool is VisualCafe 4.0.I passed the compilation.But there is a runtime throw stating NoSuchMethodError:main. Why is that? Am I missing something here?Can somebody help me?
Tks in advance!
Frances
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frances,
I ran your code with both IE and Netscape with no problem. Here is the html I used:

I've never used VisualCafe, just compiled from the command line. I don't know why VC would cause any problems, but I don't see any errors in the code itself.
Please try placing the html file above in the same directory as your MyApplet.class file and try again. If you still have problems, let us know.
Also, please be sure to register with a proper name. "Frances F" does not meet the requirements. If you do not, your account will be disabled. I would hate to see that happen. See the following link for details: http://www.javaranch.com/name.html
Thanks.
Stephanie
 
Frances Fang
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,Stephanie,
Thank you!
I tried on Microsoft IE 5.It runed OK. Does that mean Applet can only be embedded in HTML and run on browser?
Frances
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frances,
Yes, applets only run in browsers (Netscape, IE, appletviewer, etc.).
If you want to run your code independently, you need to make an application.
Here is a very simple example (all it does is open a window):

Stephanie
[This message has been edited by Stephanie Grasson (edited December 01, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic