Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization 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
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Applet ???? help

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, again.

I am trying to execute the following



/*
* This program creates an applet
* which displays text.
*/

import java.applet.*;
import java.awt.*;


public class MyFirstApplet extends Applet
{
public void paint (Graphics graphic)
{
graphic.drawString("Boo u twat", 5,5);
graphic.drawRect(3,3, 100, 20);
}//paint method
}//class

However, i am getting the following message

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

Why is this and how can i fix this???

Begginer here, so understand

Thanks
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first compile your file....

In your applet there is no main()...
further

type the following code

<applet code="MyFirstApplet.class" width = 300 height = 50>
</applet>

and save as MyFirstApplet.html

place in the same directory as your class file...

now Double Click MyFirstApplet.html

you will get your result...
 
Kay Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brilliant

Thanks Prashanth Lingala
 
Kay Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wait, before you go.

I have done as you said and it does work, but..

the display is stuck in the top left corner and no matter what i change in my code (MyFirstApplet.java) it dosn't effect html display.


i.e. The rectangle and text is always in the top left corner.
 
Prashanth Lingala
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember the CoOrdinates begin at the top left corner

0,0 -------X Coordinates------89,0
|
|
|
y Coordinate
|
|
0,10

replace your drawRect code with the following:


Try playing with coordinates...you will get the idea...
 
please buy this thing and then I get a fat cut of the action:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic