File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes ColorText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ColorText" Watch "ColorText" New topic
Author

ColorText

DB Ekanayake
Greenhorn

Joined: Apr 07, 2008
Posts: 8
Hi

I got Following codes form a Java Tut.
They compiled without any errors.But when I try to run the program it Produced the following error.

Exception in thread "main" java.lang.NoSuchMethodError: main


Can any one spend your valuable time to solve this matter

Thanks

DB



import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;

public class ColorText extends Canvas{
ColorText(){
setSize(400,120);
setBackground(Color.pink);
}

public void paint(Graphics g){
Font font;

g.setColor(Color.red);
font=new Font("Arial",Font.ITALIC | Font.BOLD,18);
g.setFont(font);
g.drawString("Arial 18 point bold italic red",10,20);

Color mycolor =new Color(0,255,0);
g.setColor(mycolor);
font=new Font("Times new Roman",Font.BOLD,22);
g.drawString("Times new Roman 22 point plain green",10,40);

g.setColor(new Color(0,0,255));
font=new Font("Monospaced",Font.BOLD,20);
g.drawString("Monospaced 20 point plain blue",10,60);
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42909
    
  68
This code is not a standalone program - it's an AWT component. It can be used by embedding it in a Frame or some other kind of AWT container. To run it, the class would also need a main method, as the error message mentions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ColorText