Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

NoSuchMethodError for JApplet

 
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
 
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
 
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).]
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic